[PHP-DB] Problem with MySQL and array loop
Hello, I've got a really strange problem. When looping through a result given by mysql_fetch_row(), the code for some reason ignores the last column in the database. The code snippet I'm using now is while($row=mysql_fetch_row($result)) { print(TR); for($i=0;$i7;$i++) { print(TD); if($row[$i]==) { print(P ALIGN=\CENTER\BN/A/B/P); } else { printf(P ALIGN=\CENTER\%s/P, $row[$i]); } print(/TD); } print(/TR); } The database has got eight columns, and I can't for the world figure out why it doesn't work. I have exactly the same problem with another PHP-app that I'm developing, too, so if someone has got a solution to my problem, I'd probably get the other app working too. What is it I'm missing, or am I just stupid? I opt for the second choice. :) Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- 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] Problem with MySQL and array loop
you're only printing stuff while i=0, i=1,i=6. therefore only 7 things come out. either make the loop for($i=0;$i=7;$i++), or for($i=0;$i8;$i++). -Original Message- From: +markus lervik [mailto:[EMAIL PROTECTED]] Sent: 13 December 2001 09:37 To: php-db Subject: [PHP-DB] Problem with MySQL and array loop Hello, I've got a really strange problem. When looping through a result given by mysql_fetch_row(), the code for some reason ignores the last column in the database. The code snippet I'm using now is while($row=mysql_fetch_row($result)) { print(TR); for($i=0;$i7;$i++) { print(TD); if($row[$i]==) { print(P ALIGN=\CENTER\BN/A/B/P); } else { printf(P ALIGN=\CENTER\%s/P, $row[$i]); } print(/TD); } print(/TR); } The database has got eight columns, and I can't for the world figure out why it doesn't work. I have exactly the same problem with another PHP-app that I'm developing, too, so if someone has got a solution to my problem, I'd probably get the other app working too. What is it I'm missing, or am I just stupid? I opt for the second choice. :) Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- 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] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.306 / Virus Database: 166 - Release Date: 04/12/01 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.306 / Virus Database: 166 - Release Date: 04/12/01 -- 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] Problem with MySQL and array loop
On Thu, 2001-12-13 at 11:42, matt stewart wrote: you're only printing stuff while i=0, i=1,i=6. therefore only 7 things come out. either make the loop for($i=0;$i=7;$i++), or for($i=0;$i8;$i++). Oh! Thanks a million! It works like a charm now. So I guess the second alternative was right, after all. Isn't it funny, how one can become code-blind regarding one own's code? -Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- 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]