Click to See Complete Forum and Search --> : Fetch Array printing to a table?


DMP23
04-14-2006, 12:18 PM
Hey guys, have a search designed but I want to pretty up the output. I want to print the results in a table( possible a few columns across and the items themselves listed in row – kinda like a list) instead of haphazardly around the page. Please advise?

Here is my search code that the table has to integrated with:

while ($row=mysql_fetch_array($result))
{
$blueprint_id=$row["blueprint_id"];
$name=$row["name"];
$location=$row["location"];
$type=$row["type"];
$storys=$row["storys"];
$bedrooms=$row["bedrooms"];
$bathrooms=$row["bathrooms"];


// how to display each row of data
echo"
blueprint_id: $blueprint_id<br>
name: $name<br>
location: <img src='$location'>
type_id: $type<br>
story_id: $storys<br>
bedrooms: $bedrooms<br>
bathrooms:$bathrooms<br>";


echo "<form method='post' action='cart.php'>";
echo "<input type='hidden' name='blueprint_id' value='$blueprint_id'>";
echo "blueprint_id :$blueprint_id | ";
echo "Quantity: <input type='text' name='quantity' value ='1' size='5'> ";
echo "<input type='submit' name='submit' value='ADD'>";
echo "</form><P>";

}

balloonbuffoon
04-14-2006, 12:34 PM
Try this:echo "<table><tr>
<td>Blueprint ID</td><td>Name</td>
<td>Location</td><td>Type ID</td>
<td>Story ID</td><td>Bedrooms</td>
<td>Bathrooms</td></tr>";
while ($row=mysql_fetch_array($result))
{
$blueprint_id=$row["blueprint_id"];
$name=$row["name"];
$location=$row["location"];
$type=$row["type"];
$storys=$row["storys"];
$bedrooms=$row["bedrooms"];
$bathrooms=$row["bathrooms"];


// how to display each row of data
echo "<tr>
<td>$blueprint_id</td><td>$name</td>
<td><img src='$location'></td><td>$type</td>
<td>$storys</td><td>$bedrooms</td>
<td>$bathrooms</td></tr>";


echo "<tr><td colspan='7'><form method='post' action='cart.php'>";
echo "<input type='hidden' name='blueprint_id' value='$blueprint_id'>";
echo "blueprint_id :$blueprint_id | ";
echo "Quantity: <input type='text' name='quantity' value ='1' size='5'> ";
echo "<input type='submit' name='submit' value='ADD'>";
echo "</form></td></tr>";

}
echo "</table>";Untested and I'm not sure if that's the look your going for.

--Steve