RE: [PHP] If you ever had a Vic20

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) &...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-15-2003
Dave Restall - System Administrator
 
Posts: n/a
Default RE: [PHP] If you ever had a Vic20

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 |
+----------------------------------------------------------------------------+

Reply With Quote
  #2 (permalink)  
Old 08-15-2003
Matt Babineau
 
Posts: n/a
Default Re: [PHP] If you ever had a Vic20

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");
>
>
>


Reply With Quote
  #3 (permalink)  
Old 08-15-2003
John Taylor-Johnston
 
Posts: n/a
Default Re: [PHP] If you ever had a Vic20

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");



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:37 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0