Bopo Posted December 13, 2008 Share Posted December 13, 2008 Hi Well basically I have a query which returns the first 50 records, and stores them within a mysql fetch array. However I want to loop through each record and output the result into a table, however I am unsure on how I would do this, here's what I have so far: result = mysql_query("SELECT * FROM cardata ORDER BY insurance_group ASC LIMIT 50"); $row = mysql_fetch_array($result); echo <<<MY_HTML <table width="250" border="1"> <table summary=""> <tr> <td>$row[model]</td> <td>$row[insurance_group]</td> </tr> <tr> <td>$row[model]</td> <td>$row[insurance_group]</td> </tr> </table> MY_HTML; // 50 rows in total, just removed all of them for clarity Link to comment https://forums.phpfreaks.com/topic/136816-loop-through-an-array/ Share on other sites More sharing options...
ted_chou12 Posted December 13, 2008 Share Posted December 13, 2008 result = mysql_query("SELECT * FROM cardata ORDER BY insurance_group ASC LIMIT 50"); echo "<table width=\"250\" border=\"1\"> <table summary=\"\">"; while ($row = mysql_fetch_array($result)) { echo " <tr> <td>{$row['model']}</td> <td>{$row['insurance_group']}</td> </tr>";} echo "</table>"; Ted Link to comment https://forums.phpfreaks.com/topic/136816-loop-through-an-array/#findComment-714546 Share on other sites More sharing options...
Bopo Posted December 13, 2008 Author Share Posted December 13, 2008 Thanks works perfectly Link to comment https://forums.phpfreaks.com/topic/136816-loop-through-an-array/#findComment-714559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.