This is a discussion on When extracting from a query the first result is not displayed? within the PHP General forums, part of the PHP Programming Forums category; This is most likely a simple problem for an advanced PHP guru, here is my code: echo "<table&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
This is most likely a simple problem for an advanced PHP guru, here is my
code: echo "<table>....."; while ($row = mysql_fetch_array($result)) {extract($row); echo "<tr><td>$roll</td><td>$run</td>.......";}; The code works fine, it simply outputs all the rows into variables from the query of choice. The only thing it doesn't do is output the first row from the query for instance when i run the script, if i use a query which has only 1 row of information it will create a blank table, if there are 2 rows of data from a query, it will only output 1 and so on. The while loop seems to skip the first row of data or altest it is not getting past the extract($row) phase I would appreciate any help someone can give. This project is for a business and will be vital to the company. thanx ##-----------------------------------------------# Article posted from PHP Freaks NewsGroup http://www.phpfreaks.com/newsgroup Get Addicted: php.genera ##-----------------------------------------------## |
|
|||
|
Ross . wrote:
> > The code works fine, it simply outputs all the rows into variables from > the query of choice. The only thing it doesn't do is output the first row > from the query for instance when i run the script, if i use a query which > has only 1 row of information it will create a blank table, if there are 2 > rows of data from a query, it will only output 1 and so on. The while > loop seems to skip the first row of data or altest it is not getting past > the extract($row) phase > Hi I use a system like this. The first item in an array is [0] so this picks it up, whereas the way you are doing it seems to start at [1]. Hope this helps Cambo $result = MYSQL_QUERY($query); $numbrows = mysql_num_rows($result); if ($numbrows==0) { echo "No Records Found !"; } else if ($numbrows>0) { echo "<table>....."; $x=0; while ($x<$numbrows) { $row = mysql_result($result,$x); {extract($row); echo "<tr><td>$roll</td><td>$run</td>.......";}; $x++; } // end while |
![]() |
| Thread Tools | |
| Display Modes | |
|
|