RE: [PHP] while loop- will this work?
| From: | Matt Schroebel | Date: | Thu, 30 Jan 2003 17:58:13 +0000 |
| Subject: | RE: [PHP] while loop- will this work? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-133675@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: SpyProductions Support Team [mailto:support@spyproductions.com]
> Sent: Thursday, January 30, 2003 12:57 PM
> To: php-general@lists.php.net
> Subject: [PHP] while loop- will this work?
>
>
>
>
> Should this work?
>
> $f1 = rand(999,99999999999);
>
> while($check_sid = mysql_query("SELECT * FROM
> that_table WHERE this =
> '$f1'")){
>
> $f1 = rand(999,99999999999);
>
> }
>
>
> i.e. put the random number in a loop to check and make sure
> it is already
> not in use?
If you check the result set for a match. $result being true will only
mean the sql executed, and not that the value was in the table. So you
should do a mysql_fetch_row($result) and if it succeeds the row exists
in the table.