JTapp Posted April 17, 2008 Share Posted April 17, 2008 Problem is my data is being returned into to separate tables instead of one table.. can somebody help me correct my mistake? Here is the table code just below my query: $result = mysql_query($query) or die(mysql_error()); while ( $row = mysql_fetch_array($result)) { echo "<table>"; echo '<table width="65%" border="2" bgcolor=\"#EBECE4\">'; echo '<td>Heading One</td>'; echo '<td><p>Heading Two</p>'; echo '<td><p>Heading Three</p>'; echo '<td><p>Heading Four</p>'; echo '<td><p>Heading Five</p>'; echo "<tr><td>". $row['fieldOne'] . "</td><td>" . $row['fieldTwo'] . "</td><td>" . $row['fieldThree'] . "</td><td>" . $row['fieldFour'] . "</td><td>" . $row['fieldFive'] . "</td></tr>"; echo "</table>"; } Link to comment https://forums.phpfreaks.com/topic/101575-solved-missing-a-simple-line-for-my-table-results-but-i-dont-know-what-it-is/ Share on other sites More sharing options...
conker87 Posted April 17, 2008 Share Posted April 17, 2008 Try (edited slighty): <?php $result = mysql_query($query) or die(mysql_error()); echo "<table>"; while ( $row = mysql_fetch_array($result)) { echo "<table width=\"65%\" border=\"2\" bgcolor=\"#EBECE4\">"; echo "<tr><td>Heading One</td><td>Heading Two</td><td>Heading Three</td><td>Heading Four</td><td>Heading Five</td></tr>"; echo "<tr><td>". $row['fieldOne'] . "</td><td>" . $row['fieldTwo'] . "</td><td>" . $row['fieldThree'] . "</td><td>" . $row['fieldFour'] . "</td><td>" . $row['fieldFive'] . "</td></tr>"; echo "</table>"; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/101575-solved-missing-a-simple-line-for-my-table-results-but-i-dont-know-what-it-is/#findComment-519554 Share on other sites More sharing options...
JTapp Posted April 17, 2008 Author Share Posted April 17, 2008 Thanks but it's still giving me two separate tables... Link to comment https://forums.phpfreaks.com/topic/101575-solved-missing-a-simple-line-for-my-table-results-but-i-dont-know-what-it-is/#findComment-519601 Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 <?php $result = mysql_query($query) or die(mysql_error()); echo "<table width=\"65%\" border=\"2\" bgcolor=\"#EBECE4\">"; while ( $row = mysql_fetch_array($result)) { echo "<tr><td>Heading One</td><td>Heading Two</td><td>Heading Three</td><td>Heading Four</td><td>Heading Five</td></tr>"; echo "<tr><td>". $row['fieldOne'] . "</td><td>" . $row['fieldTwo'] . "</td><td>" . $row['fieldThree'] . "</td><td>" . $row['fieldFour'] . "</td><td>" . $row['fieldFive'] . "</td></tr>"; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/101575-solved-missing-a-simple-line-for-my-table-results-but-i-dont-know-what-it-is/#findComment-519613 Share on other sites More sharing options...
JTapp Posted April 17, 2008 Author Share Posted April 17, 2008 Well, it merged the two tables into one table, but the headings are being repeated above each row of data... Link to comment https://forums.phpfreaks.com/topic/101575-solved-missing-a-simple-line-for-my-table-results-but-i-dont-know-what-it-is/#findComment-519619 Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 <?php $result = mysql_query($query) or die(mysql_error()); echo "<table width=\"65%\" border=\"2\" bgcolor=\"#EBECE4\">"; echo "<tr><td>Heading One</td><td>Heading Two</td><td>Heading Three</td><td>Heading Four</td><td>Heading Five</td></tr>"; while ( $row = mysql_fetch_array($result)) { echo "<tr><td>". $row['fieldOne'] . "</td><td>" . $row['fieldTwo'] . "</td><td>" . $row['fieldThree'] . "</td><td>" . $row['fieldFour'] . "</td><td>" . $row['fieldFive'] . "</td></tr>"; } echo "</table>"; ?> I should read the php more thoroughly. Link to comment https://forums.phpfreaks.com/topic/101575-solved-missing-a-simple-line-for-my-table-results-but-i-dont-know-what-it-is/#findComment-519622 Share on other sites More sharing options...
JTapp Posted April 17, 2008 Author Share Posted April 17, 2008 Thanks jonsjava - I appreciate it! Have a great day! Link to comment https://forums.phpfreaks.com/topic/101575-solved-missing-a-simple-line-for-my-table-results-but-i-dont-know-what-it-is/#findComment-519634 Share on other sites More sharing options...
conker87 Posted April 17, 2008 Share Posted April 17, 2008 <?php $result = mysql_query($query) or die(mysql_error()); echo "<table width=\"65%\" border=\"2\" bgcolor=\"#EBECE4\">"; echo "<tr><td>Heading One</td><td>Heading Two</td><td>Heading Three</td><td>Heading Four</td><td>Heading Five</td></tr>"; while ( $row = mysql_fetch_array($result)) { echo "<tr><td>". $row['fieldOne'] . "</td><td>" . $row['fieldTwo'] . "</td><td>" . $row['fieldThree'] . "</td><td>" . $row['fieldFour'] . "</td><td>" . $row['fieldFive'] . "</td></tr>"; } echo "</table>"; ?> I should read the php more thoroughly. Ditto lol Link to comment https://forums.phpfreaks.com/topic/101575-solved-missing-a-simple-line-for-my-table-results-but-i-dont-know-what-it-is/#findComment-519646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.