Jump to content

[SOLVED] PHP Not retrieving all data from MySQL?


Styles2304

Recommended Posts

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?

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

 

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.