RE: [PHP-DB] I cant get the logic for this...
Hi Dave, I wrote the following script which does exaclty that. Cami "; if ($result) { while ($list = mysql_fetch_array ($result)) { if($i==3) { $i=0; echo ""; } echo "".$list["yourvariablename"].""; $i++; if($i==3) { echo ""; } } // end while fetch_array if ($numrows%3==2){echo " ";} if ($numrows%3==1){echo " ";} } //end if numrows>0 echo ""; ?> -Original Message- From: Greg Donald [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 2:14 PM To: Dave Carrera; php List Subject: Re: [PHP-DB] I cant get the logic for this... > I want to display return results from my query (which works fine) > In I tidy way on screen. > > So my result returns say seven results, I have a table, and I want to > show > 3 results per row of the table... I.e.: > > Table > TR > TD = result1 /TD TD result2 /TD TD = result3 /TD > /TD > /TR > TR > TD = result4 /TD TD result5 /TD TD = result6 /TD > /TD > /TR > TR > TD = result7 /TD TD resultempty /TD TD = resultempty /TD > /TD > /TR > /table > > The last two td in row 3 are empty because result found 7 results. > > This cant be fixed so echo statements wont work as the result could > Be 3 or 10 or 56 or whatever. > > As Always your help and or guidance in this matter is appreciated. You need a incrementer variable so you can tell when you have 3 cells built, so you know when to end the current and start a new one. Then, you need to test that variable again when you run out of mysql_num_rows(), and fill the 1 or 2 needed cells with Also, you might wanna look around for some table building classes if your data is always gonna be really abstract. Greg Donald - http://destiney.com/ http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] I cant get the logic for this...
> I want to display return results from my query (which works fine) > In I tidy way on screen. > > So my result returns say seven results, I have a table, and I want to > show > 3 results per row of the table... I.e.: > > Table > TR > TD = result1 /TD TD result2 /TD TD = result3 /TD > /TD > /TR > TR > TD = result4 /TD TD result5 /TD TD = result6 /TD > /TD > /TR > TR > TD = result7 /TD TD resultempty /TD TD = resultempty /TD > /TD > /TR > /table > > The last two td in row 3 are empty because result found 7 results. > > This cant be fixed so echo statements wont work as the result could > Be 3 or 10 or 56 or whatever. > > As Always your help and or guidance in this matter is appreciated. You need a incrementer variable so you can tell when you have 3 cells built, so you know when to end the current and start a new one. Then, you need to test that variable again when you run out of mysql_num_rows(), and fill the 1 or 2 needed cells with Also, you might wanna look around for some table building classes if your data is always gonna be really abstract. Greg Donald - http://destiney.com/ http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] R: [PHP-DB] I cant get the logic for this...
You could use this script: $query_data[]"; } else if ($count == $columns) { $count = 0; echo "$query_data[]"; } for ($i=$count;$i<=$columns;$i++){ echo " "; } echo ""; } ?> I think it works. Bye, Moreno -Messaggio originale- Da: Dave Carrera [mailto:[EMAIL PROTECTED]] Inviato: lunedi 18 febbraio 2002 13.07 A: php List Oggetto: [PHP-DB] I cant get the logic for this... Hi all, I want to display return results from my query (which works fine) In I tidy way on screen. So my result returns say seven results, I have a table, and I want to show 3 results per row of the table... I.e.: Table TR TD = result1 /TD TD result2 /TD TD = result3 /TD /TD /TR TR TD = result4 /TD TD result5 /TD TD = result6 /TD /TD /TR TR TD = result7 /TD TD resultempty /TD TD = resultempty /TD /TD /TR /table The last two td in row 3 are empty because result found 7 results. This cant be fixed so echo statements wont work as the result could Be 3 or 10 or 56 or whatever. As Always your help and or guidance in this matter is appreciated. Dave Carrera Php / MySql Development Web Design Site Marketing http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] I cant get the logic for this...
Hi all, I want to display return results from my query (which works fine) In I tidy way on screen. So my result returns say seven results, I have a table, and I want to show 3 results per row of the table... I.e.: Table TR TD = result1 /TD TD result2 /TD TD = result3 /TD /TD /TR TR TD = result4 /TD TD result5 /TD TD = result6 /TD /TD /TR TR TD = result7 /TD TD resultempty /TD TD = resultempty /TD /TD /TR /table The last two td in row 3 are empty because result found 7 results. This cant be fixed so echo statements wont work as the result could Be 3 or 10 or 56 or whatever. As Always your help and or guidance in this matter is appreciated. Dave Carrera Php / MySql Development Web Design Site Marketing http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php