Re: [PHP] All records not displaying...
I would say enabled error_reporting(E_ALL); error_reporting(-1); Then use die(mysql_error()); with your mysql function to get some debugging data. Also use var_dump($query_name) to find out what is spits out. Debugging is your best friend here. If you don't use die() or error_reporting() then you will see a blank screen. Ravi. On Sun, Dec 19, 2010 at 9:01 PM, Gary wrote: > > "Tamara Temple" wrote in message > news:c6993909-dd90-4f52-bf6b-ab888c281...@gmail.com... > > > > On Dec 19, 2010, at 9:46 AM, Gary 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 run the query in the DB and it displays the correct result, so > it > >> has > >> to be in the php. > >> > >> 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 'Imported Beers'; > >> echo ' >> id="tableone" summary=""> > >> > >> Beer > >> Maker > >> Type > >> Singles > >> 6-Packs > >> Cans > >> Bottles > >> Draft > >> Size > >> Description'; > >> > >> while ($row = mysql_fetch_array($result)) { > >> > >> echo '' . $row['beername'].''; > >> echo '' . $row['manu'] . ''; > >> echo '' . $row['type'] . ''; > >> echo '' . $row['singles'] . ''; > >> echo '' . $row['six'] . ''; > >> echo '' . $row['can'] . ''; > >> echo '' . $row['bottles'] . ''; > >> echo '' . $row['tap'] . ''; > >> echo '' . $row['size'] . ''; > >> echo '' . $row['descrip'] . ''; > >> ''; > >>} > >> echo ''; > >> > >> } > >> > >> All but the first row in alphabetical order are displayed properly. > >> > >> Can anyone tell me where I am going wrong? > >> -- > >> Gary > >> > >> BTW, I do have a bonus question that is about javascript in this same > >> file, > >> so if anyone want to take a stab at that, I'll be happy to post it. > >> > > > > This code will totally eliminate the first row of data. > > > >> if (mysql_num_rows($result) == !'0') { > >>$row = mysql_fetch_array($result); > > > > Fetches the first row, but is not output. Because: > > > >> while ($row = mysql_fetch_array($result)) { > > > > Fetches the second row before you do any output of the data. > > > > Eliminate the first fetch_array and you're code should work fine. > > > > BTW, if you put the attributes 'width="n"' in the preceding > > tags, you won't have to output them for each row. You should also put > the > > units those numbers are associated with. > > > > > Tamara > > Thank you for your help and thank you for the explaination. I removed the > line and it works fine. I dont remember where or why I had that line in > there, it is code that I have "recycled" for a while now. > > Gary > > > > __ Information from ESET Smart Security, version of virus signature > database 5716 (20101219) __ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] All records not displaying...
"Tamara Temple" wrote in message news:c6993909-dd90-4f52-bf6b-ab888c281...@gmail.com... > > On Dec 19, 2010, at 9:46 AM, Gary 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 run the query in the DB and it displays the correct result, so it >> has >> to be in the php. >> >> 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 'Imported Beers'; >> echo '> id="tableone" summary=""> >> >> Beer >> Maker >> Type >> Singles >> 6-Packs >> Cans >> Bottles >> Draft >> Size >> Description'; >> >> while ($row = mysql_fetch_array($result)) { >> >> echo '' . $row['beername'].''; >> echo '' . $row['manu'] . ''; >> echo '' . $row['type'] . ''; >> echo '' . $row['singles'] . ''; >> echo '' . $row['six'] . ''; >> echo '' . $row['can'] . ''; >> echo '' . $row['bottles'] . ''; >> echo '' . $row['tap'] . ''; >> echo '' . $row['size'] . ''; >> echo '' . $row['descrip'] . ''; >> ''; >>} >> echo ''; >> >> } >> >> All but the first row in alphabetical order are displayed properly. >> >> Can anyone tell me where I am going wrong? >> -- >> Gary >> >> BTW, I do have a bonus question that is about javascript in this same >> file, >> so if anyone want to take a stab at that, I'll be happy to post it. >> > > This code will totally eliminate the first row of data. > >> if (mysql_num_rows($result) == !'0') { >>$row = mysql_fetch_array($result); > > Fetches the first row, but is not output. Because: > >> while ($row = mysql_fetch_array($result)) { > > Fetches the second row before you do any output of the data. > > Eliminate the first fetch_array and you're code should work fine. > > BTW, if you put the attributes 'width="n"' in the preceding > tags, you won't have to output them for each row. You should also put the > units those numbers are associated with. > > Tamara Thank you for your help and thank you for the explaination. I removed the line and it works fine. I dont remember where or why I had that line in there, it is code that I have "recycled" for a while now. Gary __ Information from ESET Smart Security, version of virus signature database 5716 (20101219) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] All records not displaying...
I'm not sure what this line us all about: if (mysql_num_rows($result) == !'0') You're basically saying; if the number of rows is equal to the not of the string 0, what I think you may want in this case is just != 0. The next line is causing your problem though. You're grabbing the first row with that $row= line, and not doing anything with it. Take that out and it should be ok. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Gary" Date: Sun, Dec 19, 2010 15:46 Subject: [PHP] All records not displaying... To: 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 run the query in the DB and it displays the correct result, so it has to be in the php. 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 'Imported Beers'; echo ' Beer Maker Type Singles 6-Packs Cans Bottles Draft Size Description'; while ($row = mysql_fetch_array($result)) { echo '' . $row['beername'].''; echo '' . $row['manu'] . ''; echo '' . $row['type'] . ''; echo '' . $row['singles'] . ''; echo '' . $row['six'] . ''; echo '' . $row['can'] . ''; echo '' . $row['bottles'] . ''; echo '' . $row['tap'] . ''; echo '' . $row['size'] . ''; echo '' . $row['descrip'] . ''; ''; } echo ''; } All but the first row in alphabetical order are displayed properly. Can anyone tell me where I am going wrong? -- Gary BTW, I do have a bonus question that is about javascript in this same file, so if anyone want to take a stab at that, I'll be happy to post it. __ Information from ESET Smart Security, version of virus signature database 5715 (20101219) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] All records not displaying...
On Dec 19, 2010, at 9:46 AM, Gary 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 run the query in the DB and it displays the correct result, so it has to be in the php. 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 'Imported Beers'; echo ' Beer Maker Type Singles 6-Packs Cans Bottles Draft Size Description'; while ($row = mysql_fetch_array($result)) { echo '' . $row['beername'].''; echo '' . $row['manu'] . ''; echo '' . $row['type'] . ''; echo '' . $row['singles'] . ''; echo '' . $row['six'] . ''; echo '' . $row['can'] . ''; echo '' . $row['bottles'] . ''; echo '' . $row['tap'] . ''; echo '' . $row['size'] . ''; echo '' . $row['descrip'] . ''; ''; } echo ''; } All but the first row in alphabetical order are displayed properly. Can anyone tell me where I am going wrong? -- Gary BTW, I do have a bonus question that is about javascript in this same file, so if anyone want to take a stab at that, I'll be happy to post it. This code will totally eliminate the first row of data. if (mysql_num_rows($result) == !'0') { $row = mysql_fetch_array($result); Fetches the first row, but is not output. Because: while ($row = mysql_fetch_array($result)) { Fetches the second row before you do any output of the data. Eliminate the first fetch_array and you're code should work fine. BTW, if you put the attributes 'width="n"' in the preceding tags, you won't have to output them for each row. You should also put the units those numbers are associated with. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] All records not displaying...
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 run the query in the DB and it displays the correct result, so it has to be in the php. 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 'Imported Beers'; echo ' Beer Maker Type Singles 6-Packs Cans Bottles Draft Size Description'; while ($row = mysql_fetch_array($result)) { echo '' . $row['beername'].''; echo '' . $row['manu'] . ''; echo '' . $row['type'] . ''; echo '' . $row['singles'] . ''; echo '' . $row['six'] . ''; echo '' . $row['can'] . ''; echo '' . $row['bottles'] . ''; echo '' . $row['tap'] . ''; echo '' . $row['size'] . ''; echo '' . $row['descrip'] . ''; ''; } echo ''; } All but the first row in alphabetical order are displayed properly. Can anyone tell me where I am going wrong? -- Gary BTW, I do have a bonus question that is about javascript in this same file, so if anyone want to take a stab at that, I'll be happy to post it. __ Information from ESET Smart Security, version of virus signature database 5715 (20101219) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php