Page 1 of 1

combining data from two fields, displaying with another tabl

Posted: Thu Feb 27, 2003 3:49 am
by horstuff
What I am trying to do is pull data from two tables and display it on one page. The code below doesn't display any errors, but all it prints is the results from the first query. Ideas? Thanks.

(I also need to somehow put a variable in for the warranty table data so it is tied to the product_status table data. You can see there is a WHERE in the first query of pid, but no WHERE in the second query. That is a seperate question, though. It would make this way too long, so I will post it separately).

Code: Select all

<?php

include "configgg.php";

if (isset($hostname) and isset($database) and isset($db_login) and isset($db_pass)) {

    $dbconn = mysql_connect($hostname, $db_login, $db_pass) or die("Could not connect");
    mysql_select_db($database) or die("Could not select database");

    if (!isset($pid)) {
        $pid = 0;
}
             $query = "SELECT product_name FROM product_status WHERE product_id='$pid'";
             $result = mysql_query($query) or die("Query failedeww");

             $line = mysql_fetch_array($result);

       $product_name = $line[0];

       print "<html><body>";

                 print "<p align='center'><font face='arial' size='2'><b>$line[0]</b></font></p>";

             $query = "SELECT warranty_comment,aw_tag FROM warranty";
             $result = mysql_query($query) or die("Query failedeww");

             $line = mysql_fetch_array($result);
       $warranty_comment = $line[1];
       $aw_tag = $line[2];

                 print "<p align='center'><font face='arial' size='2'><b>$line[1]</b></font></p>";
                 print "<p align='center'><font face='arial' size='2'>$line[2]</font></p>";


                 print "</body></html>";

    mysql_close($dbconn);
}

?>