Click here to Skip to main content
15,896,398 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Below is my while loop table, currently it's showing just one item per row. I can't seem to figure out how to get 4 items/columns to show before it shows a new row below. Any help with this would be much appreciated, thank you!


Jerome

PHP
<table style="background-color: white">


<?php
				while ($row = mysql_fetch_array($rs)) {
	?>

PHP
<tr <?php //if ($i % 2) echo ' style="background-color: #ECECFB;"';?>>	
<td class="rows"><font color="4D4D4D" size="3"><? echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank>'.$row["Name"].'</a>' ?><br />
<? echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank><img src='.$row["Picture"].' height=210px width=141px></a>' ?><br />
<? echo '('.$row["Type"].')' ?>   <? echo $row["Year"] ?>   <? echo $row["Rating"] ?>   <? echo date('H:i', mktime(0,$row["Length"])); ?><br />
<? echo $row["Genre"] ?><br />
<? if ($row["Queue"]==='x') { 
echo 
"<center><a title=Remove From Watch List href='deletequeue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Minus.png'></a></td></font></center>"; 
} 
else { 
echo "<center><a title=Add To Watch List href='addqueue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Plus.png'></a></td></font></center>"; 
}
?>
</td></tr></font>
<?php $i++?>
<?php
}
?>
</table>
Posted
Updated 14-Oct-14 8:10am
v3

1 solution

I only see one <td> set - per row - you need one for each column. It's rather congested looking code - spaces and newlines are free - and should be used to easy readability.

roughly, you'd want to have a format as follows:
<table>

for(your loop pars) {
 ECHO   <tr>
 ECHO "<td> $value1 </td>"
 ECHO "<td> $value2 </td>"
 ECHO "<td> $value3 </td>"
 ECHO "<td> $value4 </td>"
 ECHO   </tr>
}

</table>

Each iteration through the loop creates a row in the table

.
 
Share this answer
 
v2
Comments
Maciej Los 14-Oct-14 15:49pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900