Jump to content

Display Problem


runthis

Recommended Posts

i was hoping for a fancier way than putting an if statement in my loop

 

Lets say i display 20 items and the last 2 are off the page, ok i set my if statement to 18 and throw in the <tr></tr> to display the next 2 underneath

that means if i want the user to display 56 things i have to code if 18 <tr></tr> if 36<tr></tr>

 

Thats bad coding, is there a better way?

Link to comment
https://forums.phpfreaks.com/topic/207514-display-problem/#findComment-1084909
Share on other sites

okay fast coding

assume i have 15 records n i wish each row to have only 2 records to be displayed then

i will do like this

 

<table><tr>

<?php

$myrecord=array("bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla","bla");

$td=1;

for($i=0;$i<count($myrecord);$i++){

if($td==3){

echo "</tr><tr>";

$td=1;}

echo "<td>$myrecord[$i]</td>";

$td++;

}

?>

</tr></table>

 

Link to comment
https://forums.phpfreaks.com/topic/207514-display-problem/#findComment-1084916
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.