RE: [PHP] Endless 'while' loops?
From: Jay Blanchard (jay.blanchard_at_niicommunications.com)
Date: 10/30/03
- Next message: Marek Kilimajer: "Re: [PHP] Japanese entry into MySQL and into emails"
- Previous message: Alexander Mueller: "Re: [PHP] session_regenerate_id()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Oct 2003 06:21:36 -0600 To: "Dave G" <ml@autotelic.com>, <php-general@lists.php.net>
[snip]
But in the rest of the script I can't find where they declare and fill
this array.
[/snip]
The subscriber array is filled by the query. Since PHP is not a strongly
typed language there is no need to declare the array.
$sql = "SELECT `foo`, `bar` FROM `customers` WHERE `status` = 'active'";
/*run the query, testing as we go*/
if(!($result = mysql_query($sql, $connection_string))){
echo "MySQL reports an error " . mysql_error() . "\n";
exit();
}
/*if the query worked the $result 'holds' the info*/
while ( $subscriber = mysql_fetch_row($result)){
echo $subscriber[0]."\t"; should have info from foo column
echo $subscriber[1]."\n"; should have info from bar column
}
When mysql_fetch_row($result) returns FALSE the while loop exits.
- Next message: Marek Kilimajer: "Re: [PHP] Japanese entry into MySQL and into emails"
- Previous message: Alexander Mueller: "Re: [PHP] session_regenerate_id()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|