Records not being displayed

I have an issue that the first record in a query is not being displayed. It
seems that the first row in alphabetical order is not being brought to the
screen.

I have a MySQL DB that lists beers. I have a column for 'type' of beer
(imported, domestic, craft, light). The queries:

$result = MySQL_query("SELECT * FROM beer WHERE type = 'imported' AND stock
= 'YES' ORDER by beername ");

When I run the query

if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);

echo '<h3>Imported Beers</h3>';
echo '<table width="100%" border="0" cellspacing="1" cellpadding="1"
id="tableone" summary="">

<th>Beer</th>
<th>Maker</th>
<th>Type</th>
<th>Singles</th>
<th>6-Packs</th>
<th>Cans</th>
<th>Bottles</th>
<th>Draft</th>
<th>Size</th>
<th>Description</th>';

while ($row = mysql_fetch_array($result)) {

echo '<tr ><td>' . $row['beername'].'</td>';
echo '<td>' . $row['manu'] . '</td>';
echo '<td>' . $row['type'] . '</td>';
echo '<td width="40">' . $row['singles'] . '</td>';
echo '<td width="20">' . $row['six'] . '</td>';
echo '<td width="40">' . $row['can'] . '</td>';
echo '<td width="20">' . $row['bottles'] . '</td>';
echo '<td width="40">' . $row['tap'] . '</td>';
echo '<td>' . $row['size'] . '</td>';
echo '<td>' . $row['descrip'] . '</td>';
'</tr>';
}
echo '</table>
';

}

All but the first row in alphabetical order are displayed properly.

Can anyone tell me where I am going wrong?
--
Gary



__________ Information from ESET Smart Security, version of virus signature database 5715 (20101219) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
gary [ So, 19 Dezember 2010 15:18 ] [ ID #2051840 ]

Re: Records not being displayed

--0016361e844e146e910497c55e35
Content-Type: text/plain; charset=ISO-8859-1

Your very first mysql_fetch_array consumes the first result.

On Dec 19, 2010 8:19 AM, "Gary" <gpaul [at] paulgdesigns.com> wrote:

I have an issue that the first record in a query is not being displayed. It
seems that the first row in alphabetical order is not being brought to the
screen.

I have a MySQL DB that lists beers. I have a column for 'type' of beer
(imported, domestic, craft, light). The queries:

$result = MySQL_query("SELECT * FROM beer WHERE type = 'imported' AND stock
= 'YES' ORDER by beername ");

When I run the query

if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);

echo '<h3>Imported Beers</h3>';
echo '<table width="100%" border="0" cellspacing="1" cellpadding="1"
id="tableone" summary="">

<th>Beer</th>
<th>Maker</th>
<th>Type</th>
<th>Singles</th>
<th>6-Packs</th>
<th>Cans</th>
<th>Bottles</th>
<th>Draft</th>
<th>Size</th>
<th>Description</th>';

while ($row = mysql_fetch_array($result)) {

echo '<tr ><td>' . $row['beername'].'</td>';
echo '<td>' . $row['manu'] . '</td>';
echo '<td>' . $row['type'] . '</td>';
echo '<td width="40">' . $row['singles'] . '</td>';
echo '<td width="20">' . $row['six'] . '</td>';
echo '<td width="40">' . $row['can'] . '</td>';
echo '<td width="20">' . $row['bottles'] . '</td>';
echo '<td width="40">' . $row['tap'] . '</td>';
echo '<td>' . $row['size'] . '</td>';
echo '<td>' . $row['descrip'] . '</td>';
'</tr>';
}
echo '</table>
';

}

All but the first row in alphabetical order are displayed properly.

Can anyone tell me where I am going wrong?
--
Gary



__________ Information from ESET Smart Security, version of virus signature
database 5715 (20101219) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=johnny [at] pixelated.net

--0016361e844e146e910497c55e35--
Johnny Withers [ So, 19 Dezember 2010 16:50 ] [ ID #2051841 ]

Re: Records not being displayed

Johnny

Thank you for your response, and you are correct. I have used that same
code for a number of other files and dont recall having that problem
(unfortunately, my recollection abilities seem to be withering).

So I removed the following lines and all works fine....I just wish I could
recall why I had it in the first place.

if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);

Again, thank you for your help.

Gary


"Johnny Withers" <johnny [at] pixelated.net> wrote in message
news:AANLkTik3nHJqkc00iw-NV1qqPDeaJ1_5xTWbf7skdko7 [at] mail.gmai l.com...
> Your very first mysql_fetch_array consumes the first result.
>
> On Dec 19, 2010 8:19 AM, "Gary" <gpaul [at] paulgdesigns.com> wrote:
>
> I have an issue that the first record in a query is not being displayed.
> It
> seems that the first row in alphabetical order is not being brought to the
> screen.
>
> I have a MySQL DB that lists beers. I have a column for 'type' of beer
> (imported, domestic, craft, light). The queries:
>
> $result = MySQL_query("SELECT * FROM beer WHERE type = 'imported' AND
> stock
> = 'YES' ORDER by beername ");
>
> When I run the query
>
> if (mysql_num_rows($result) == !'0') {
> $row = mysql_fetch_array($result);
>
> echo '<h3>Imported Beers</h3>';
> echo '<table width="100%" border="0" cellspacing="1" cellpadding="1"
> id="tableone" summary="">
>
> <th>Beer</th>
> <th>Maker</th>
> <th>Type</th>
> <th>Singles</th>
> <th>6-Packs</th>
> <th>Cans</th>
> <th>Bottles</th>
> <th>Draft</th>
> <th>Size</th>
> <th>Description</th>';
>
> while ($row = mysql_fetch_array($result)) {
>
> echo '<tr ><td>' . $row['beername'].'</td>';
> echo '<td>' . $row['manu'] . '</td>';
> echo '<td>' . $row['type'] . '</td>';
> echo '<td width="40">' . $row['singles'] . '</td>';
> echo '<td width="20">' . $row['six'] . '</td>';
> echo '<td width="40">' . $row['can'] . '</td>';
> echo '<td width="20">' . $row['bottles'] . '</td>';
> echo '<td width="40">' . $row['tap'] . '</td>';
> echo '<td>' . $row['size'] . '</td>';
> echo '<td>' . $row['descrip'] . '</td>';
> '</tr>';
> }
> echo '</table>
';
>
> }
>
> All but the first row in alphabetical order are displayed properly.
>
> Can anyone tell me where I am going wrong?
> --
> Gary
>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature
> database 5715 (20101219) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=johnny [at] pixelated.net
>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature database 5715 (20101219) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>



__________ Information from ESET Smart Security, version of virus signature database 5715 (20101219) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
gary [ So, 19 Dezember 2010 17:07 ] [ ID #2051842 ]
Datenbanken » gmane.comp.db.mysql.general » Records not being displayed

Vorheriges Thema: Error in mysql replication with LOAD DATA INFILE
Nächstes Thema: MySQL 5.5.8 GA's library files have not version information by default?