MDanz Posted March 19, 2010 Share Posted March 19, 2010 this code allows me to display results in column of 8, then start a new row, then 8 columns etc. what i need is the first cell(first row , first column) to be empty... so the first row only has 7 results. so for a test the first cell would echo "TEST"... how do i adjust this code to get that? $query_result = mysql_query("SELECT * FROM `table`") or die("Error");; $total = mysql_num_rows($query_result); $row_count = ceil($total / ; echo "<table>"; // loop through rows for($row = 0; $row < $row_count; $row++) { // output start of row echo "<tr>"; // loop through columns for($col = 0; $col < 8; $col++) { // grab next row $row_data = mysql_fetch_assoc($query_result); if($row_data != FALSE) { // data in array, output cell contents echo "<td>" . $row_data['field'] . "</td>"; } else { // no data left in our array // output a blank box to finish table echo "<td> </td>"; } } // close row echo "</tr>"; } // close table echo "</table>"; Link to comment https://forums.phpfreaks.com/topic/195806-help-on-display-code/ Share on other sites More sharing options...
trq Posted March 20, 2010 Share Posted March 20, 2010 if ($row == 0 && $col == 0 ) { echo "<td>TEST</td>"; } else { // grab next row $row_data = mysql_fetch_assoc($query_result); if ($row_data != FALSE) { // data in array, output cell contents echo "<td>" . $row_data['field'] . "</td>"; } else { // no data left in our array // output a blank box to finish table echo "<td> </td>"; } } Link to comment https://forums.phpfreaks.com/topic/195806-help-on-display-code/#findComment-1028923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.