OriginalSunny Posted March 25, 2006 Share Posted March 25, 2006 The trouble i am is that all the headings for my table are being output and then the values in the columns are being output below the table. I want them in the following format:OrderID 200 233 ...Surname Smith Terry ......The code i am using is:[i]echo "<table cellspacing='20'>";$connect = connect_to_db("cnn.inc");$query = "select * from products";$result = mysql_query($query,$connect)or die("sql_del: ".mysql_error($connect));echo "<tr>OrderID</tr><br>";while($row = mysql_fetch_array($result)) {echo "<td>";echo($row['orderID'].'<br>');echo"</td>";}echo "<tr>Surname</tr><br>";while($row1 = mysql_fetch_array($result)) {echo "<td>";echo($row['surname'].'<br>');echo"</td>";}[/i]I cant see what i have done wrong here. In addition to this only the values for orderID are output and the values stored for surname are not ouput unless i get rid of the array displaying the orderID's. Your help would be appreciated.Thanks. Quote Link to comment Share on other sites More sharing options...
annihilate Posted March 25, 2006 Share Posted March 25, 2006 How about this?[code]<?$connect = connect_to_db("cnn.inc");$query = "SELECT * FROM products";$result = mysql_query($query,$connect) or die("sql_del: ".mysql_error($connect));echo '<table cellspacing="20">';while($row = mysql_fetch_array($result)) {echo '<tr><td>OrderID</td><td>'.$row['orderID'].'</td></tr> <tr><td>Surname</td><td>'.$row['surname'].'</td></tr>';}echo '</table>';?>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted March 25, 2006 Share Posted March 25, 2006 As I said in previous topic of yours, data in tables needs to go in a cell eg <TD>data</TD>You have rows like this[code]echo "<tr>OrderID</tr><br>";[/code]where the text isn't inside a cell and the <br> isn't even in a row (and completely unnecessary) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.