[PHP-DB] losing first row of an array
having this code running PHP4.0b2 $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row = mysql_fetch_array($result)) { do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); } else .blablabla is there a fundamental miss on my part why the is printing the first or not even recognising it if call direct in mysql with the above query it's fine with the results even if there is 1 row duh??? Seany -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] losing first row of an array
On Friday, November 2, 2001, at 01:09 PM, Seany wrote: having this code running PHP4.0b2 $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); Here you've fetched the first row... if ($row = mysql_fetch_array($result)) { ...and here you've overwritten it with the second row. You probably just want: if ($row) { ... do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); } else .blablabla is there a fundamental miss on my part why the is printing the first or not even recognising it if call direct in mysql with the above query it's fine with the results even if there is 1 row duh??? Seany -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] losing first row of an array
You are overwriting the first row. $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); if(mysql_num_rows()) while ($row = mysql_fetch_array($result) { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } else .blablabla ...Or... $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row) do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); else .blablabla -Original Message- From: Seany [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 2:09 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] losing first row of an array having this code running PHP4.0b2 $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row = mysql_fetch_array($result)) { do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); } else .blablabla is there a fundamental miss on my part why the is printing the first or not even recognising it if call direct in mysql with the above query it's fine with the results even if there is 1 row duh??? Seany -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] losing first row of an array
nice spot I went blind for a min.lol is there any to write columns first but still call fields with headers? as writing in a table would not allow keeping tr tags open ie. echocol[1]; echocol[2]; array_flip do the job? but how? Sean Matthew Loff [EMAIL PROTECTED] wrote in message 005c01c163e0$5716ca20$0ce60281@bang">news:005c01c163e0$5716ca20$0ce60281@bang... You are overwriting the first row. $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); if(mysql_num_rows()) while ($row = mysql_fetch_array($result) { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } else .blablabla ...Or... $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row) do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); else .blablabla -Original Message- From: Seany [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 2:09 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] losing first row of an array having this code running PHP4.0b2 $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row = mysql_fetch_array($result)) { do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); } else .blablabla is there a fundamental miss on my part why the is printing the first or not even recognising it if call direct in mysql with the above query it's fine with the results even if there is 1 row duh??? Seany -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] losing first row of an array
I don't quite get what you're asking... Could you be more specific? -Original Message- From: Seany [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 5:48 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] losing first row of an array nice spot I went blind for a min.lol is there any to write columns first but still call fields with headers? as writing in a table would not allow keeping tr tags open ie. echocol[1]; echocol[2]; array_flip do the job? but how? Sean Matthew Loff [EMAIL PROTECTED] wrote in message 005c01c163e0$5716ca20$0ce60281@bang">news:005c01c163e0$5716ca20$0ce60281@bang... You are overwriting the first row. $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); if(mysql_num_rows()) while ($row = mysql_fetch_array($result) { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } else .blablabla ...Or... $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row) do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); else .blablabla -Original Message- From: Seany [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 2:09 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] losing first row of an array having this code running PHP4.0b2 $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row = mysql_fetch_array($result)) { do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); } else .blablabla is there a fundamental miss on my part why the is printing the first or not even recognising it if call direct in mysql with the above query it's fine with the results even if there is 1 row duh??? Seany -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] losing first row of an array
Nice to see someone else is up! Most times I print result sets as given is inside a do echo$row[fieldname] while loop but when putting html with it ie. building a table tr td td td td tr etc...etc. you have to close rows before starting new cells data is then shown fieldname1 fieldname2 data_for_row1 data_for_row1 data_for_row2 data_for_row2 what i would like to do is transpose data so as to write as shown like this fieldname1 data_for_row1 data_for_row2 fieldname2 data_for_row1 data_for_row2 I think a for while do loop would work with ++ inexing but u lose the field calling ability any ideas?? or is it just 12.40am here in the UK Cheers Sean Matthew Loff [EMAIL PROTECTED] wrote in message 006401c163fd$bbb34bd0$0ce60281@bang">news:006401c163fd$bbb34bd0$0ce60281@bang... I don't quite get what you're asking... Could you be more specific? -Original Message- From: Seany [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 5:48 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] losing first row of an array nice spot I went blind for a min.lol is there any to write columns first but still call fields with headers? as writing in a table would not allow keeping tr tags open ie. echocol[1]; echocol[2]; array_flip do the job? but how? Sean Matthew Loff [EMAIL PROTECTED] wrote in message 005c01c163e0$5716ca20$0ce60281@bang">news:005c01c163e0$5716ca20$0ce60281@bang... You are overwriting the first row. $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); if(mysql_num_rows()) while ($row = mysql_fetch_array($result) { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } else .blablabla ...Or... $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row) do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); else .blablabla -Original Message- From: Seany [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 2:09 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] losing first row of an array having this code running PHP4.0b2 $result = mysql_query(SELECT clubac.id AS clubacid, clubac.club_id, clubac.ac_year, clubac.ac_type, club.id FROM clubac, club WHERE club.id = '$club_id' AND clubac.club_id = club.id); $row = mysql_fetch_array($result); if ($row = mysql_fetch_array($result)) { do { echo $row[club_id]; echo $row[id]; echo $row[ac_year]; echo $row[ac_type]; } while($row = mysql_fetch_array($result)); } else .blablabla is there a fundamental miss on my part why the is printing the first or not even recognising it if call direct in mysql with the above query it's fine with the results even if there is 1 row duh??? Seany -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]