Forum Moderators: coopster
I'm very new to php scripting and haven't quite figured out what I need to do here.
I need to display information in a 1 row/2 column table. I have the MySQL query working fine, but the scripting part in php is killing me!
In the first column a graphic about 70x70 will be shown (plus some additional padding). In the second column will be the description information. The second column will be around 400 pixels wide.
How do I set this up in php? It's easy enough in HTML, but I've about killed myself trying to figure out how to properly lay this out in php!
Thanks for any help
Jim
<?
mysql_connect("localhost", "user", "pass");
mysql_select_db("database");
$query = "SELECT * FROM `table`";
$result = mysql_query($query);echo '<table>';
while ($row = mysql_fetch_array($result))
{
echo "<tr>
<td>
Content of first cell e.g. $row[field_name]
</td>
<td>
Content of second cell e.g. $row[other_field_name]
</td>
</tr>";
}
echo '</table>';
mysql_close();
?>
[edited by: barns101 at 9:27 pm (utc) on July 27, 2006]
Thanks for the help. The SQL query is working just fine. What I'm having problem with is presenting the information ok. This is what I have so far:
while ($row = mysql_fetch_array($results)){
extract($row);
echo "<table class='mainContent'>";
echo "<tr>";
echo "<td width='80'>";
echo "<img src=$image_url width='70' height='70'";
echo "</td>";
echo "<td width='420'>";
echo "<a href=$url>$hotel_name</a>";
echo "<font class='DynamicBookDescription'> : $description</font>";
echo "</td>";
echo "</tr>";
}
-- All information is displayed - so the SQL query is working properly. Things are even laid out semi-ok. The problem is that the table that is being created is somehow completely throwin off my site layout. For whatever reason, the table seems to be punching through my fixed width layout I use. I set - or at least I thought I did, this table to be 500 pixels wide. Yet, the table seems to want to span full-width of the monitor.
Not sure why!
What am I doing wrong?
Jim