Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
数据未在php中显示_Php_Mysql_Join_Phpmyadmin - Fatal编程技术网

数据未在php中显示

数据未在php中显示,php,mysql,join,phpmyadmin,Php,Mysql,Join,Phpmyadmin,我有一个PHP脚本显示预订详细信息。它工作正常,显示日期、时间、医生和房间 <!DOCTYPE html> <?php session_start(); ?> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" />

我有一个PHP脚本显示预订详细信息。它工作正常,显示日期、时间、医生和房间

<!DOCTYPE html>
<?php
session_start();
?>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />
        <title>
        </title>
        <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
        <link rel="stylesheet" href="my.css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
        </script>
        <script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js">
        </script>
        <script src="my.js">
        </script>
        <!-- User-generated css -->
        <style>
        </style>
        <!-- User-generated js -->
        <script>
            try {

    $(function() {

    });

  } catch (error) {
    console.error("Your javascript has an error: " + error);
  }
        </script>
     </head>
    <body>
        <!-- Home -->
        <div data-role="page" id="page1">
            <div data-theme="a" data-role="header">
            <a data-role="button" data-theme="d" href="login.html" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left">
                    Back
                </a>
                <a data-role="button" href="index.html" data-icon="home" data-iconpos="right" data-theme="d"class="ui-btn-right">
                 Home  
                </a>
                <h3>
                    Book appointment
                </h3>
           </div>

           <div data-role="content">
                <h3>
                    Select date/time:
                </h3>
                <br />
<?php
{
    mysql_connect("localhost" , "" , "") or die (mysql_error());
    mysql_select_db("") or die(mysql_error());


    $pid=intval($_SESSION["Patient_id"]); $query = "SELECT t1.*, t2.Doctor_name, t2.Doctor_room FROM Appointment AS t1 INNER JOIN Doctor AS t2 ON t1.Doctor_id=t2.Doctor_id";

    //executes query on the database
    $result = mysql_query ($query) or die ("didn't query");

    //this selects the results as rows
    $num = mysql_num_rows ($result);    

    //if there is only 1 result returned than the data is ok 
    if ($num == 1) {}
    {
        $row=mysql_fetch_array($result);
        $_SESSION['Appointment_date'] = $row['Appointment_date'];
        $_SESSION['Appointment_time'] = $row['Appointment_time'];
        $_SESSION['Doctor_name'] = $row['Doctor_name'];
        $_SESSION['Doctor_room'] = $row['Doctor_room'];
    }
}
?>  

        <strong>Dates available</strong>            
        <select id="Availability" name="Availability">                      
        <option value="0">--Select date--</option>
        <option value="3"><?php echo $_SESSION['Appointment_date'];?></option>
        </select>

        <br />
        <br />

        <strong>Times available</strong>            
        <select id="Availability" name="Availability">                      
        <option value="0">--Select time--</option>
        <option value="3"><?php echo $_SESSION['Appointment_time'];?></option>>
        </select>

        <br />
        <br />

            <strong>Doctor Name</strong>            
        <select id="Availability" name="Availability">                      
        <option value="0">--Name--</option>
        <option value="2"><?php echo $_SESSION['Doctor_name'];?></option>>
        </select>

        <br />
        <br />

            <strong>Doctor Room</strong>            
        <select id="Availability" name="Availability">                      
        <option value="0">--Room--</option>
        <option value="2"><?php echo $_SESSION['Doctor_room'];?></option>>
        </select>

        <br />
        <br />

                <label for="textarea1">
                Message GP
                </label>
                <textarea name="" id="textarea1" placeholder="">
                </textarea>

                <br />
                <br />

        <a data-role="button" data-theme="a" href="booked.php">
                    Book Appointment
                </a>  

             </div>
        </div>
    </body>
</html>
我进入phpmyadmin并插入了另一个约会,以便用户可以选择,但此约会不显示,仅显示一个。有什么想法吗


谢谢

这实际上是一个有趣的错误

if ($num == 1) {}
    {
        $row=mysql_fetch_array($result);
        $_SESSION['Appointment_date'] = $row['Appointment_date'];
        $_SESSION['Appointment_time'] = $row['Appointment_time'];
        $_SESSION['Doctor_name'] = $row['Doctor_name'];
        $_SESSION['Doctor_room'] = $row['Doctor_room'];
    }
您将其设置为仅当$num==1时显示数据,但由于这些额外的{},即使记录不止一条,也会显示数据。因为该显示不在if块内,并且if对您的显示没有任何影响。但是,您没有看到更多记录的原因是,您只获取了一次,而不是在循环中

必须是这样的

while($row=mysql_fetch_assoc($result))
{
        $_SESSION['Appointment_date'] = $row['Appointment_date'];
        $_SESSION['Appointment_time'] = $row['Appointment_time'];
        $_SESSION['Doctor_name'] = $row['Doctor_name'];
        $_SESSION['Doctor_room'] = $row['Doctor_room'];
}

你看过医生的诊断表了吗。。??确保从phpmyadmin添加的记录属于doctor表中可用的现有医生。如果$num==1,请尝试删除。如果$num==1{},我会看到什么?为什么会有一个空块?你应该试着通过打印我们的变量来解决问题,看看哪里出了问题。使用var_dump$var;调查并查看在何处生成的内容。仅尝试了您建议的代码,没有出现错误,但仍然没有显示其他日期和时间。如果$num==1,则变量$numSame中返回的记录数是多少?这意味着查询返回的记录不超过1条,如果$num>0,则还需要进行修复。。。。。