itzknowledge Posted April 11, 2008 Share Posted April 11, 2008 ok so i have this cms, and it displays the titles of the post ontop of each other in a single row, for example title3 title2 title1 what i want it to do is display it 4 in a row and then move ontop and start a new row, for example title8 title7 title6 title5 title4 title3 title2 title1 this is the code i have for the page: <?php database_connect(); $query = "SELECT * from content WHERE status = 1 ORDER by position;"; $error = mysql_error(); if (!$result = mysql_query($query)) { print "$error"; exit; } while($rij = mysql_fetch_object($result)){ $title = $rij->title; $id = $rij->id; print("<a href=\"page.php?id=$id\" target=\"_self\"><strong>$title</strong></a>"); } ?> can somebody please help me fix this. Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted April 11, 2008 Share Posted April 11, 2008 well first of all you don't even have a table set up. Quote Link to comment Share on other sites More sharing options...
itzknowledge Posted April 11, 2008 Author Share Posted April 11, 2008 i tried to set up a table but all it does is strech it Quote Link to comment Share on other sites More sharing options...
poleposters Posted April 11, 2008 Share Posted April 11, 2008 A table is probably the easiest way . Create a html page with a table in it, and fill it with dummy data similar to what might be retrieved from your database.Once you can get the HTML table to render correctly, just insert the HTML in the appropriate places in your script. Below is a script that creates rows of three fields. you can modify it to display rows of four.Basically it tests which record has been retrieved. Ie the first, second ,third etc and displays the corresponding HTML code to allow it to be positioned correctly. $count=0; $getmaincats="SELECT * from cl_categories where CatParent='0'"; $getmaincats2=mysql_query($getmaincats) or die("Could not get root categories"); print "<table class='maintable'>"; while($getmaincats3=mysql_fetch_array($getmaincats2)) { if($count%3==0) { print "<tr class='rows'><td class='columns'><A href='index.php?catid=$getmaincats3[CatID]'><b>$getmaincats3[CatName]</b></a><br>$getmaincats3[Catdescription]</td>"; } else if($count%3==1) { print "<td class='columns'><A href='index.php?catid=$getmaincats3[CatID]'><b>$getmaincats3[CatName]</b></a><br>$getmaincats3[Catdescription]</td>"; } else { print "<td class='columns'><A href='index.php?catid=$getmaincats3[CatID]'><b>$getmaincats3[CatName]</b></a><br>$getmaincats3[Catdescription]</td></tr>"; } $count++; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.