This is a discussion on RE: [PHP] If you ever had a Vic20 within the PHP General forums, part of the PHP Programming Forums category; Hi, > $found =3D 0; > while ($mydata =3D mysql_fetch_object($news)) > { > if ($mydata->StudentId =3D=3D $StudentId) &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
> $found =3D 0; > while ($mydata =3D mysql_fetch_object($news)) > { > if ($mydata->StudentId =3D=3D $StudentId) > {$found =3D 1; break;} > } > > if ($found=3D=3D1){do this}else{do that} Why not re-oganise your SQL statement so it only returns the required data ?. "select * from table where StudentID = $StudentID"; if (mysql_num_rows() == 1) do this; else do that; Vic 20's were for wimps ;-) TTFN Dave mail/php/2003-08-15.tx jt.johnston@usherbrooke.ca martin.towell@world.net php-general@lists.php.net jay.blanchard@niicommunications.com +----------------------------------------------------------------------------+ | Dave Restall, IIRC Limited, PO Box 46, Skelton, Cleveland, TS12 2GT. | | Tel. +44 (0) 1287 639309 Mob. +44 (0) 7973 831245 Fax. +44 (0) 1287 635955 | | email : dave@iirc.net dave@restall.net Web : http://www.iirc.net | +----------------------------------------------------------------------------+ | I owe the public nothing. | | -- J.P. Morgan | +----------------------------------------------------------------------------+ |
|
|||
|
mysql_num_rows($news)
On Fri, 2003-08-15 at 17:42, John Taylor-Johnston wrote: > OK, > I tried this, but am getting this error: > Warning: Wrong parameter count for mysql_num_rows() in /.../testals.php on line 189 > 189> if (mysql_num_rows() == 1) > What's up? > John > > $myconnection = mysql_connect($server,$user,$pass); > mysql_select_db($db,$myconnection); > > $news = mysql_query("select StudentId from $table where StudentID = $StudentID"); > > if (mysql_num_rows() == 1) > include ("./html/access_error.htm"); > else > include ("./html/registration.htm"); > > > |
|
|||
|
OK,
I tried this, but am getting this error: Warning: Wrong parameter count for mysql_num_rows() in /.../testals.php on line 189 189> if (mysql_num_rows() == 1) What's up? John $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $news = mysql_query("select StudentId from $table where StudentID = $StudentID"); if (mysql_num_rows() == 1) include ("./html/access_error.htm"); else include ("./html/registration.htm"); |