Log in

View Full Version : Display info from two tables.



9erNumber16
04-30-2012, 03:39 AM
I'm trying to display information from more than one table using PHP and mySQL. The embedded mySQL script works on its own, but I can't get anything to display when I do it in PHP. Here is the PHP file:



<?php
$con = mysql_connect("info");// connect to db
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("CSCI340-04", $con);

$checkSsn = $_POST[Ssn];
//retrieve the appointments of the desired patient
$sql="Select P.Fname, P.Lname, D.Fname, D.Lname, A.Time, A.Date from PATIENT AS P, DOCTOR AS D, APPOINTMENT AS A where A.Patient_ssn = '$checkSsn' and A.Doctor_ssn = D.Ssn and A.Patient_ssn = P.Ssn";

result = mysql_query($sql);

while($row = mysql_fetch_array($result))//print results
{
echo $row['Fname'] . " " . $row['Lname'] . " " . $row['Fname'] . " " . $row['Lname'] . " " . $row['Time'] . " " . $row['Date'];
echo "<br />";
}

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}


mysql_close($con);
?>

9erNumber16
04-30-2012, 03:46 AM
Ok, now I'm having the problem again

9erNumber16
04-30-2012, 05:42 AM
Never mind, again. Missed a $.

ApacheTech
05-01-2012, 07:24 PM
I was going to say...


$result = mysql_query($sql);