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);
?>
<?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);
?>