display mysql results in threes
Posted: Sun Jul 24, 2011 11:59 pm
okay, so I'm fairly new to MySQL and PHP, but like to think I am a fast learner...
my problem:
I select a number of rows from a MySQL database (let's see fifteen) and want to display them in a table... but I want three results on each row (so it would be a 3x5 table). how do I do that? I know that I can display each result on a new line/row like this:
or I can select each piece of data individually - but that would be quite longwinded - there must be an easier way!
my problem:
I select a number of rows from a MySQL database (let's see fifteen) and want to display them in a table... but I want three results on each row (so it would be a 3x5 table). how do I do that? I know that I can display each result on a new line/row like this:
Code: Select all
$qry = "SELECT * FROM table LIMIT 15";
$rsl = mysql_query($qry, $db) or die(mysql_error($db));
while($row = mysql_fetch_array($rsl)){
echo $row['data'] . "<br />\n";
}