proctk Posted August 6, 2006 Share Posted August 6, 2006 HiBelow is code that get data from a table an displays it on the page. I'm trying to figure out a way so that instead of displaying as a vertical list it displays across the screen. say three enteries side by side. when the line is full it would move down to next row[code=php:0]<?include 'db.php'; $user_id = $_SESSION['user_id'];$child_query= ("SELECT * FROM children WHERE user_id = '$user_id'OR Otheruser_id = '$user_id'")or die("Create table Error: ".mysql_error());$child_result=mysql_query($child_query)or die("Create table Error: ".mysql_error());$child_num=mysql_numrows($child_result);mysql_close();$i=0;while ($i < $child_num) {$childfistname = mysql_result($child_result,$i,"childfirstname");$childlastname = mysql_result($child_result,$i,"childlastname");$childdob = mysql_result($child_result,$i,"childdob");$childsex = mysql_result($child_result,$i,"childsex");$childage = round(dateDiff("/", date("m/d/Y", time()), $childdob)/365, 0);$child_id = mysql_result($child_result,$i,"child_id");echo "<p class='$childsex'><b>First Name:</b> $childfistname<br><b>Last Name:</b> $childlastname<br><b>DOB:</b> $childdob<br><b>Age:</b> $childage<br><a href='UpdateChildren.php?id=$child_id&user_id=$user_id'>Edit</a><a href='deleteChild.php?id=$child_id&user_id=$user_id'>Delete</a></p>";$i++;}?> [/code] Link to comment https://forums.phpfreaks.com/topic/16744-format-out-put/ Share on other sites More sharing options...
tomfmason Posted August 7, 2006 Share Posted August 7, 2006 I under stand what you are trying to do. Personaly I wouldn't have went about it this way. You should try a [code=php:0]mysql_fetch_assoc[/code].Here is an example[code=php:0]while ($rw = mysql_fetch_assoc($child_result)) { echo '<p class="' . $rw['childsex'] . '"><b>First Name:</b>' . $rw['childfistname'] . '<br><b>Last Name:</b>' . $rw['childlastname'] . '<br><b>DOB:</b>' . $rw['childdob'] . '<br><b>Age:</b>' . $rw['childage'] . '<br><a href="UpdateChildren.php?id=' . $rw['child_id'] . '&user_id=' . $user_id . '">Edit</a><a href="deleteChild.php?id=' . $rw['child_id'] . '&user_id=' . $user_id . '">Delete</a>';}mysql_free_result($child_result);[/code]I wrote this on the fly so you may want to check over it. It should give you a basic idea. Link to comment https://forums.phpfreaks.com/topic/16744-format-out-put/#findComment-70419 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.