Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts

    trying to display results from php query into html table

    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 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++;
    }

    ?>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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.

    .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •