View Single Post
Old 12-13-2012, 01:23 PM   PM User | #4
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Something like the following although I'm unable to test it currently.

PHP Code:
<?php
$result 
mysql_query("SELECT * from patterns WHERE cattxt = 'Wreaths' ORDER BY dsptxt"); 
$split 0;
echo 
"<table><tr>";
while(
$row mysql_fetch_array($result)) 

    echo 
"<td><a href=\"".$row['lnktxt']."\">".$row['dsptxt']."</a></td>";
    if (
$split++ % 2) {    // or (($split++ % 2) == 1)
        
echo "</tr><tr>";
    } 
}
if (
$split 2) {
    echo 
"</tr></table>";
} else {
    echo 
"<td></td></tr></table>";    // or "<td>&nbsp;</td></tr></table>"
}
?>
In particular, I may have the last two echoes the wrong way round(?).

You might end up with a blank row, so it needs a little more work. Added: to get around this you could, instead, create a string and check what occurs at the end of this string - and amend it accordingly.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS

Last edited by AndrewGSW; 12-13-2012 at 01:35 PM..
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
mharrison (12-13-2012)