...

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



Buffmin
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)



<?php

mysql_connect("mydb.perfora.net",$username,$password);
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); ;
$num=mysql_numrows($result);
mysql_close();

$i=0;

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

$business=mysql_result($result,$i,"BusinessName");
$contact=mysql_result($result,$i,"Contact");
$address1=mysql_result($result,$i,"Address1");
$picture_name=mysql_result($result,$i,"picture_name");


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

$i++;
}

?>

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

<style>
tr{
height:190px;
}
</style>

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

.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum