When extracting from a query the first result is not displayed?

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&...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2004
Ross .
 
Posts: n/a
Default When extracting from a query the first result is not displayed?

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
##-----------------------------------------------##
Reply With Quote
  #2 (permalink)  
Old 02-18-2004
cambo
 
Posts: n/a
Default Re: When extracting from a query the first result is not displayed?

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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:11 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0