Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.