Jump to content

Recommended Posts

<?php
$i = 0; //set variable I as 0
echo '<div style="float:left;">'; //start a division.
while($row = mysql_fetch_assoc($result)) { //fetch the data.
if(++$i == 5) { //if $i has passed 4 which means 4 lines have been printed, close the division and open another.
       echo '</div><div>';
}
echo implode(',<br />',$row); //echo the data.
}
echo '</div>'; //close the final division.

I wirte this code for 4 * 4 :

echo "<div><ul>";
$c = 1;
$media = mysql_query("SELECT * FROM " . "$prefix" . "screen where id=\"$id\" order by id desc limit 16");
while ($cms = mysql_fetch_assoc($media)) {

  if (!($c%4)) echo ($c!=0 ? "</ul>" : "")."<ul>";

    echo "<li><a href=\"#\"><img src=\"#\"></a></li>\n";

    $c++;
        }

    echo "</ul></div>\n";

  for ($cnt=$c;$cnt%4>0;$cnt++);
?>

 

Html output is :

 

<UL>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
</UL>
<UL>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
</UL>
<UL>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
</UL>
<UL>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
    <li><a href=\"#\"><img src=\"#\"></a></li>
</UL>
<UL>
    <li><a href=\"#\"><img src=\"#\"></a></li>
</UL>

 

This is false . actually i need to each <UL> 4 <LI> . What's problem !

 

Thanks.

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.