mysql - PHP query not listing first result -


this question has answer here:

so i've found whenever i'm building query first/"oldest" result not show. here's code -

    $data=mysql_query("select * `horses`  inner join `awards` on horses.hname=awards.hname `hid`=$id"); $row=mysql_fetch_object($data); echo mysql_error();  while ($row = mysql_fetch_object($data)) {     echo"$row->award<br>";  } 

when lists awards, if have 1 entry listed won't list anything. if have two, it'll list newest of two. -

$data=mysql_query("select * `v_testhorses`  `hid`=$id"); $row=mysql_fetch_object($data); echo mysql_error();  echo"<tr><td><center>$row->hname ($row->type)</td></tr>"; echo"<tr><td>$row->yob $row->gender owned $row->oname ($row->stable)</td></tr>"; echo"<tr><td>$row->sire x $row->dam  </td></tr>"; echo"</table><br><br>";  echo"<table>"; echo"<tr><td>year</td><td>win</td><td>place</td><td>show</td><td>tokens</td><td>earnings</td></tr>";  while ($row = mysql_fetch_object($data)) {     echo"<tr><td>$row->year</td>";     echo"<td>$row->wins</td>";     echo"<td>$row->place</td>";     echo"<td>$row->show</td>";     echo"<td>$row->tokens</td>";     echo"<td>$" . number_format($row->lte) . "</td></tr>";  } 

will list recent years, ignoring first/earliest entry. suggestions? (i know old php every time try change newer version crashes - , i'm still learning :( )

you calling mysql_fetch_object() twice.

$data=mysql_query("select * `horses`  inner join `awards` on horses.hname=awards.hname `hid`=$id"); // $row=mysql_fetch_object($data); <--------- remove me echo mysql_error();  while ($row = mysql_fetch_object($data)) {     echo"$row->award<br>";  } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -