Reputation: 580
I have this array populating from mysql. But it is not showing me the first record. I can't figure out what the problem is. It should be simple. Here is the code.
$result=mysql_query("SELECT user_instance.instance_name, user_instance.host_name FROM
dba_account, user_instance WHERE dba_account.account_id = user_instance.account_id AND
dba_account.account_id = '1'");
echo mysql_error();
$nume = mysql_fetch_row($result);
while($note = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><input type='text' name='instance_name' class='instance_name'
disabled='disabled' value='$note[instance_name]' size='25' /></td>";
echo "<td><input type='text' name='host_name' class='host_name' disabled='disabled'
value='$note[host_name]' size='25' /></td>";
echo "</tr>";
}
Upvotes: 0
Views: 90
Reputation: 270607
The first time you call mysql_fetch_row()
, it advances the result resource pointer to the second result. Don't do that. Especially considering you are not using the variable $nume
in your loop in any way, it is unnecessary and harmful to your logic.
// Don't do this!
//$nume = mysql_fetch_row($result);
// Instead just fetch the loop
while($note = mysql_fetch_array($result)) {
// etc...
}
Upvotes: 4
Reputation: 9891
You're fetching the first row in $nume = mysql_fetch_row. That pulls the first record. Then you're iterating through the rest of the records in your while loop. Remove that first line.
Upvotes: 6