dodgei Posted January 24, 2007 Share Posted January 24, 2007 I'm having trouble mixing html code with php.I want to display my database query result in a table with each field in a separate colomn.I will be using a loop to access the records. Since I dont konw how many records will be retrieved I dont know how many cells the table will have.How can I create a new table row and <td> with each record retrieved? Link to comment https://forums.phpfreaks.com/topic/35596-mixing-html-with-php/ Share on other sites More sharing options...
chronister Posted January 24, 2007 Share Posted January 24, 2007 Start your table before a while loop, and put your table row inside the loop and it will print a row for each result.[code]<?php$query="SELECT * FROM table";$result=mysql_query($query);?><table width="50%" align="center" border="0"><?phpwhile($row=mysql_fetch_assoc($result)){echo '<tr><td>'.$row[fieldname].'</td><tr>';}?></table>[/code] Link to comment https://forums.phpfreaks.com/topic/35596-mixing-html-with-php/#findComment-168573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.