Results 1 to 4 of 4

Thread: Display info from two tables.

  1. #1
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Display info from two tables.

    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:

    Code:
    <?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);
    ?>
    Last edited by 9erNumber16; 04-30-2012 at 04:00 AM.

  2. #2
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, now I'm having the problem again
    Last edited by 9erNumber16; 04-30-2012 at 04:00 AM.

  3. #3
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Never mind, again. Missed a $.

  4. #4
    Join Date
    Apr 2012
    Location
    Chester, Cheshire
    Posts
    329
    Thanks
    7
    Thanked 35 Times in 35 Posts

    Default

    I was going to say...

    Code:
    $result = mysql_query($sql);

Bookmarks

Posting Permissions

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