| | |
PHP Tables
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2007
Posts: 36
Reputation:
Solved Threads: 0
Hi All:
I'm connecting to a db to populate a table. My code loops through the db without errors. The problem is in Firefox, my rows of data display as individual tables. Everything works perfect in IE. Any ideas what I'm missing? The table population code basically looks like this:
Also, if I place the ">" inside the curly bracket to close the table tag, IE displays each row as a table. So, echoing the ">" after the curly bracket fixed that problem. I've been coding for 9 hours, so I'm sure I'm just missing something obvious.
Thanks for the help!
I'm connecting to a db to populate a table. My code loops through the db without errors. The problem is in Firefox, my rows of data display as individual tables. Everything works perfect in IE. Any ideas what I'm missing? The table population code basically looks like this:
<?php echo " <table> <tr> <td>$col1</td> <td>$col2</td> <td>$col3</td> </tr> </table"; } echo ">"; ?>
Also, if I place the ">" inside the curly bracket to close the table tag, IE displays each row as a table. So, echoing the ">" after the curly bracket fixed that problem. I've been coding for 9 hours, so I'm sure I'm just missing something obvious.
Thanks for the help!
What buddylee said. What does the source to your page look like? It's probably not correct at all but IE happens to display it correctly.
You need something like this:
foreach documentation
You need something like this:
php Syntax (Toggle Plain Text)
echo '<table>'; while ($row = mysql_fetch_array($result)){ //loop through the rows echo '<tr>'; foreach ($row as $element){ //loop through elements (ie td's) echo "<td>$element</td>"; } echo '</tr>'; } echo '</table>';
★ "If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
humbug's code is correct.
The only reason that IE appeared to be displaying the table correctly is because the table code was invalid and the closing table tag was not being recognized. Each table was therefore not being completed.
Browsers correct a lot of coding problems while they attempt to render the page, which is probably why FireFox was displaying separate tables. It looks like you were creating separate tables and FireFox was correcting the coding error.
The only reason that IE appeared to be displaying the table correctly is because the table code was invalid and the closing table tag was not being recognized. Each table was therefore not being completed.
Browsers correct a lot of coding problems while they attempt to render the page, which is probably why FireFox was displaying separate tables. It looks like you were creating separate tables and FireFox was correcting the coding error.
![]() |
Similar Threads
- Basic PHP Includes (PHP)
- Reverse Auction Application for Merchants & Service Providers PHP (Post your Resume)
- How would I write this asp code to work in PHP (PHP)
- PHP newbie, project feasibility (PHP)
- Upadating booking page with php (PHP)
- updating 2 HTML tables on one PHP page (PHP)
- DB-Authentication php/mysql on Mac OSX v3 (PHP)
- Fun with Forms (PHP)
Other Threads in the PHP Forum
- Previous Thread: Chmod with a timer
- Next Thread: oscommerce
Views: 2282 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class clean cms code countingeverycharactersfromastring cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail match menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions simple sms soap source space spam speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





