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?

Link to comment
Share on other sites

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.

 

 

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.