Styles2304 Posted November 18, 2008 Share Posted November 18, 2008 at the moment there are five names in a database; the code is supposed to retrieve them and spit them out next to a check box. <?php $RowCount = 0; $query = "SELECT FirstName, LastName, IndexNo FROM UserInfo ORDER BY LastName"; $result = mysql_query($query, $link) or die(mysql_error()); $AdminAbilities = ''; while ($row = mysql_fetch_array($result)) { $IndexNo = $row['IndexNo']; $FName = $row['FirstName']; $LName = $row['LastName']; if ($RowCount == 3) { $AdminAbilities .=<<<EOD </tr> <tr> EOD; $RowCount = 0; } else { $AdminAbilities .=<<<EOD <td width="15" valign="middle" align="center"> <input type="checkbox" name="Admin" value="$IndexNo"> </td> <td width="163" valign="middle" align="left"> $LName, $FName </td> EOD; $RowCount++; } } ?> The problem is it only retrieves 4 of the 5. Any ideas? Link to comment https://forums.phpfreaks.com/topic/133151-solved-php-not-retrieving-all-data-from-mysql/ Share on other sites More sharing options...
ohdang888 Posted November 18, 2008 Share Posted November 18, 2008 this is how you are setting it up: if ($RowCount == 3) { //display admin } else { //display data } when the row count is number 3, its not being display... rather, just use this:(don't use the else) if ($RowCount == 3) { //display admin } //display data Link to comment https://forums.phpfreaks.com/topic/133151-solved-php-not-retrieving-all-data-from-mysql/#findComment-692515 Share on other sites More sharing options...
Styles2304 Posted November 18, 2008 Author Share Posted November 18, 2008 Ah thanks, it's always something simple. Link to comment https://forums.phpfreaks.com/topic/133151-solved-php-not-retrieving-all-data-from-mysql/#findComment-692525 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.