louis_coetzee Posted February 2, 2009 Share Posted February 2, 2009 I have a table |id|userid|name |surname |detail| |1 | 2 |Elisha |Cuthbert | Hot | |2 | 2 |Sara |Monroe | Okay | What I want to do is, fetch this from mysql and display it in a html table. I realise that I did it wrong, but please help me do it the right way... $result = mysql_query("SELECT * FROM Celebs where userid = '$userid'"); $size = count($result); if (size !== 0) { echo '<table width="500" border="1" cellpadding="4" cellspacing="0" class="boderstyle"> <tr class="menuitems"> <td width="16" bgcolor="#666666"><strong>ID</strong></td> <td width="70" bgcolor="#666666"><strong>Name</strong></td> <td width="153" bgcolor="#666666"><strong>Surname</strong></td> <td width="122" bgcolor="#666666"><strong>Detail</strong></td> </tr>'; for($k=1; $k <= $size; $k++) { while ($row = mysql_fetch_array($result)) { $id = $row['id']; $name = $row['name']; $surname = $row['surname']; $detail = $row['detail']; } echo '<tr> <td height="31" class="one">'.$id.'</td> <td>'.$name.'</td> <td>'.$surname.'</td> <td>'.$detail.'</td> </tr>'; } echo '</table>'; } Link to comment https://forums.phpfreaks.com/topic/143457-mysql-table-to-html-table-3d-arrayplease-help/ Share on other sites More sharing options...
.josh Posted February 2, 2009 Share Posted February 2, 2009 http://www.phpfreaks.com/tutorial/php-basic-database-handling Link to comment https://forums.phpfreaks.com/topic/143457-mysql-table-to-html-table-3d-arrayplease-help/#findComment-752516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.