RE: [PHP] If you ever had a Vic20

From: Date: Fri, 15 Aug 2003 07:08:54 +0000
Subject: RE: [PHP] If you ever had a Vic20
Groups: php.general 
Request: Send a blank email to php-general+get-159646@lists.php.net to get a copy of this message
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:taylorjo@collegesherbrooke.qc.ca] Sent: Friday, 15 August 2003 4:52 PM To: php-general@lists.php.net 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}

« previous php.general (#159646) next »