Hello DP! So I'm working on an awesome new site, completely coding it by myself. Most of it is DIV instead of tables, but I'll be having some tabular data in the middle so I figured I'd use tables instead of div's for that part. I am looking for a little help with a problem I'm having though. So, I have a table, like this: <table> <tr> <td>Name One</td> <td>Name Two</td> <td>Name Three</td> <td>Name Four</td> <td>Name Five</td> <tr> <td>Age One</td> <td>Age Two</td> <td>Age Three</td> <td>Age Four</td> <td>Age Five</td> </tr> </table> Code (markup): I want each name and age to be pulled from a sql table. The table consists of 5 peoples names and ages. Would it be best to call it from one statement, such as this: $statement = "SELECT * FROM table"; Code (markup): And use a while() loop inside the HTML table? (I tried doing that but it didn't work quite right cause of the structure of the table) Or would it be best to use multiple select statements and number each one? I'm using this on a site where it will be selecting upwards of 100 rows, that would be alot of select statements. Can someone steer me in the right direction?
<?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM table"); echo "<table border='1'> <tr> <th>Name</th> <th>Age</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Name'] . "</td>"; echo "<td>" . $row['Age'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Code (markup): ok i think thats what u need