View Full Version : trying to display results from php query into html table

11-21-2011, 07:18 PM
Hello, I am fairly new to php and struggling with this. I am querying a database and displaying the results, but it looks boring (just 1 column with a number of vertical td cells), but works. Rather, I would like to display this data as I currently am, but would like to have a 2nd column to the right where I could display their image (logo). My problem is that the 2nd column automatically has an equal number of rows, so if I insert an image in 1st cell in the 2nd column, that row will expand in height to the height of the image, and in effect, so will the corresponding cell (to the left) in the 1st column, and my table looks terrible.

I would appreciate it if someone could show me the "right" way to do this. Should I use div's instead? I understand div's and CSS, but do not know how to display the data in divs. I would appreciate any help. Sincerely Buffmin

Here is my code (I removed some variables to shorten the code)


mysql_select_db($database) or die("unable to select");
$query = "SELECT * FROM `mybiz` WHERE `Type` LIKE '%$name%' ";
$result=mysql_query($query)or die("Failed Query of " . $query); ;


echo "<table border=2 bordercolor=red width=800px cellpadding=4>\n";
while ($i<$num) {


echo " <TR><TD>$business</TD><td>$picture_name</td>\n";
echo " <TR><TD>$contact</TD></TR>\n";
echo " <TR><TD>$address1</TD></TR>\n";
echo " <TR><TD>$picture_name</TD></TR>\n";
echo "</TABLE>";

echo "<b><font size = 5><font color=green>$business </b> </font size><BR>" ;
echo "<b><font size = 4> $contact </font size></B><br>";
echo "<b><font size = 3> $address1 <br>";
if($picture_name<>"") echo "<IMG SRC= images/$picture_name width=240 height=180 ><BR>";
echo "<BR> <br>";



11-21-2011, 08:56 PM
Put this above your PHP .. in your HTML


See if that forces all rows to be the same height regardless of an image or not.