View Single Post
  #10 (permalink)  
Old 01-30-04, 01:43 PM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there, sorry about the limiting thing. You need to reset the fetched <td>s each time, which I forgot to add. But together with your request, here it is:

PHP Code:

echo '<table>';


// Note that $res is mysql result id.
// $i keeps track of the number of rows (<tr>).
// In this example, you will get 12 items/cells in total = $i(4) * $j(3).
for ($i 0$i 4$i++) {
    
    
// New row starts.
    
echo '<tr>';
    
    
// $j keeps track of the number of cols (<td>).
    // In this example there will be 3 <td>'s per <tr>
    
for ($j 0$j 3$j++) {
        
        
// See if there is still a fetchable row in the result.
        
if ($row mysql_fetch_array($res)) {
            echo 
'<td>'.$row[0].'</td>';
        }
        
// If not, show the dummy link.
        
else {
            echo 
'<td><a href="submit.php">Submit Yours</a</td>';
        }
    
    }
    
    
// This row ends.
    
echo "</tr>\n";

}

echo 
'</table>'
Note that I'm echoing right away instead of fetching it. Also, this time I tested it, so there should be no problem. If you still want to use the output-once-in-the-end approach, try reseting the fetched columns after echoing it.

Hope this helps. Sorry about the hassle.
__________________
Blavv =|
Reply With Quote