Jump to content


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


format out put

Recommended Posts


Below 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



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());




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>





Share this post

Link to post
Share on other sites
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

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>';

I wrote this on the fly so you may want to check over it. It should give you a basic idea.

Share this post

Link to post
Share on other sites


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.