Jump to content

SQL / PHP with 0/0 results with 1 record.. SQL bug?


Recommended Posts

I ran a SQL query and received 0/0 results but still returned 1 record.

 

This is causing a problem with my php page because I need to echo the 1 record results. I thought it was a problem with my php code, but after running the query directly in myPhpAdmin I see why it can't echo the results.

 

Here is a screen shot of the query.

whats_up_query.gif

 

Anybody have any idea why this is happening and if there is a way to still echo something like $query['GameID'] when I get a record set like this?

I ran a SQL query and received 0/0 results but still returned 1 record.

 

This is causing a problem with my php page because I need to echo the 1 record results. I thought it was a problem with my php code, but after running the query directly in myPhpAdmin I see why it can't echo the results.

 

According to what phpMyAdmin is saying you're viewing 0 to 0 and you have 1 total record.

 

If you had 5 records total in your table, it would show 0 - 4 (5 Total.... ). If you have 100 and you're looking at page 2 (with the default pagination) it would show 31 - 60 ( 100 Total... ).

 

If that's the only record in the table, then phpMyAdmin is correct and it may be your php script. But if you have more than only 1 record in your table, then you may be correct.

 

 

 

 

 

So records sets start at 0

 

There is tons of data in the table, but only that one result for the specific query. When I try to echo the result with that query I can't get the GameID or Multiplier

 

I am using an array though so maybe that is the issue?

 

$where = '';
$range = implode(',',range('A','T'));
foreach($_POST['checkbox'] as $checkbox)
{
$where .= "'" . $checkbox . "' IN (" . $range . ") AND ";
}
$where .= "Game_Date='" . $select . "'";
$chunk1 ="SELECT * FROM june122011 Where ";
$query = $chunk1 . $where;
$doit=mysql_query($query);
$results=mysql_fetch_array($doit);

 

While ($results = mysql_fetch_array($doit)) {
echo "<tr><td><span class='stdblackbld'>$results[GameID]</span></td>";
echo "<td class='smallblack'><span class='stdTxtYellowBold'> x$results[Multiplier]</span></td></tr>";
}

Your line with:

$results=mysql_fetch_array($doit);

gets the first row from your table. You don't seem to be doing anything with that row .

 

Your line with:

While ($results = mysql_fetch_array($doit)) {

gets the next (=2nd) row from your table.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.