Dylan Dylan - 2 months ago 8
MySQL Question

How to make SQL results display in different vertical columns?

So I have my results displaying, only they're displaying in 1 column down the webpage. I would like them to display in 5 columns

Heres my code

$query = "SELECT * FROM mytable LIMIT 5";
$result = mysql_query($query);

echo "<table>";

while($row = mysql_fetch_array($result)){
echo "
<table width='100%' style='padding-right:50px; padding-left: 50px;'>

<td><img id='dvdCovers' src='". $row['FIELD4'] ."'/>
<br>

<a id='tcMain'>". $row['FIELD1'] ." <a> ". $row['FIELD2'] ."</tc>
<tr>

</table>
";

Answer
$query = "SELECT * FROM mytable LIMIT 5"; 
$result = mysql_query($query);

echo " <table width='100%' style='padding-right:50px; padding-left: 50px;'>"; 

while($row = mysql_fetch_array($result)){   
echo "<tr>
        <td><img id='dvdCovers' src='". $row['FIELD4'] ."'/></td>
        <td><a id='tcMain'>". $row['FIELD1'] ." <a></td>
        <td> ". $row['FIELD2'] ."</td></tr>";
}
echo "</table>"; 
Comments