RE: [PHP] MySQL Query Result Question
| From: | Van Andel, Robbert | Date: | Fri, 28 Feb 2003 23:44:12 +0000 |
| Subject: | RE: [PHP] MySQL Query Result Question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-137649@lists.php.net to get a copy of this message | ||
Yes, your correction is actually what I have. So the problem I'm facing is that $result
doesn't seem to empty when I run the query and nothing is returned by it.
Robbert van Andel
-----Original Message-----
From: Bryan Lipscy [mailto:x427279616e@monroe.net]
Sent: Friday, February 28, 2003 3:40 PM
To: Van Andel, Robbert; php-general@lists.php.net
Subject: RE: [PHP] MySQL Query Result Question
Shouldn't that be:
while($data=mysql_fetch_array($result))
{
//SSLT
}
NOTE: Added ) and changes $query to $result
-----Original Message-----
From: Van Andel, Robbert [mailto:RVanAndel@chartercom.com]
Sent: Friday, February 28, 2003 3:21 PM
To: php-general@lists.php.net
Subject: [PHP] MySQL Query Result Question
I have the following query:
$query = "SELECT d.utilization, d.capacity_date, d.day, i.id,
i.interface, cd.date, cd.id ";
$query .= "FROM (capacity_data as d LEFT JOIN interfaces as i ON
d.interface = i.id) ";
$query .= "LEFT JOIN capacity_date as cd ON d.capacity_date=cd.id ";
$query .= "WHERE i.router = '$cmts[$i]' AND cd.date >= '$useDate'
";
$query .= "ORDER BY i.interface,cd.date DESC";
if(!$result = mysql_query($query)) die(mysql_error());
while($data=mysql_fetch_array($query)
{
//SSLT
}
The query itself runs just fine. However, I've run into a problem with
the loop I've created. During one of the iterations, the query returns
no data so during the subsequent loop the previous query's results is
used in it's place. I do not want this to happen. What is the best way
to destroy $result before I run the query?
Robbert van Andel