Failing_Solutions Posted June 24, 2011 Share Posted June 24, 2011 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. 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? Quote Link to comment https://forums.phpfreaks.com/topic/240286-sql-php-with-00-results-with-1-record-sql-bug/ Share on other sites More sharing options...
WStudio Posted June 24, 2011 Share Posted June 24, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240286-sql-php-with-00-results-with-1-record-sql-bug/#findComment-1234193 Share on other sites More sharing options...
Failing_Solutions Posted June 24, 2011 Author Share Posted June 24, 2011 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>"; } Quote Link to comment https://forums.phpfreaks.com/topic/240286-sql-php-with-00-results-with-1-record-sql-bug/#findComment-1234198 Share on other sites More sharing options...
EdwinPaul Posted June 24, 2011 Share Posted June 24, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240286-sql-php-with-00-results-with-1-record-sql-bug/#findComment-1234200 Share on other sites More sharing options...
Failing_Solutions Posted June 24, 2011 Author Share Posted June 24, 2011 That was it thanks Edwin! Quote Link to comment https://forums.phpfreaks.com/topic/240286-sql-php-with-00-results-with-1-record-sql-bug/#findComment-1234203 Share on other sites More sharing options...
EdwinPaul Posted June 24, 2011 Share Posted June 24, 2011 You're welcome. btw: you do not check for successfull completion of your database-actions. You should! Quote Link to comment https://forums.phpfreaks.com/topic/240286-sql-php-with-00-results-with-1-record-sql-bug/#findComment-1234221 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.