What about (just a slight change...)? $found = 0; while ($mydata = mysql_fetch_object($news)) { if ($mydata->StudentId == $StudentId) {$found = 1; break;} }
if ($found==1){do this}else{do that} at least this way you don't need to go through all the other records if it's found near the start... [OT] - Vic-20 - hmmm, them were the days... Martin -----Original Message----- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Friday, 15 August 2003 4:52 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] If you ever had a Vic20 Ok ... so I can do it this way (below), but there must be a more intelligent way? This is like something I did with my Vic20, 19 years ago. (If you ever had a Vic20 ... :) you might sympathise) while ($mydata = mysql_fetch_object($news)) { if ($mydata->StudentId = $StudentId) {$found =1}else{$found=0} } if ($found==1){do this}else{do that} > $myconnection = mysql_connect($server,$user,$pass); > mysql_select_db($db,$myconnection); > > $news = mysql_query("select StudentId FROM $table"); > > while ($mydata = mysql_fetch_object($news)) > { > } > > if exists > {do this}else{do that} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php