First, i'd like to start with a blank page. We'll try it this way, and if you dont like it, you can always try and incorporate it into your code - but i'm going to try and streamline it as much as possible. Also not gonna give you the code straight out, want to see if you can follow my logic!
Establish your database link.
Here's the SELECT query i would use;
FROM `leads` AS l
LEFT JOIN `ValidISP` AS s
ON l.IPISP = s.ISP AND l.IPCheck = 'NO';
Note the Left Join here. This makes sure all leads are pulled, even if they dont have a matching ISP. You probably want to add an ORDER BY too, but we're not overly stressed about the order of items atm.
foreach row in the result set
All rows should have one of three results in the 'Status' column; 'PASS', 'FAIL', or NULL.
If status is null, make it MANUAL.
assign the leadid to a new element one of three elements of a new array - i'm gonna call it $update. (hint: the keys of the elements should match your status). This will result in a 2-dimensional array.
EFE; we are now done selecting our data.
Now to update it!
foreach element of $update;
if the count of elements of this key is greater than 0,
SET IPCheck = '<elementname>'
WHERE LeadID IN ('<imploded list of elements of this element, seperated by commas. no quotes around this.>');
EDIT: Added an if to counter the 0-updates, and formatting on the queries to make them more readable.
I'm also moderately sure you could do this whole script in a single query, but i'm gonna have to tap @guido2004 and make sure i'm not sticking my foot in my mouth again.