我怎么能写这个PHP代码只获取具体信息?

时间:2015-10-21 01:02:06

标签: php mysql mysqli

我无法弄清楚这一点。假设我有一个约会工具来安排约会。对于每个约会,我都有一个附加形式,显示仅针对该约会的特定信息。

现在,当用户点击一个名为form的按钮时,它会将他们带到这个附加页面上的另一个页面,我想显示另一个约会列表,但只显示与被点击的约会相同的名称。

在数据库的约会表中,名称存储在lep中。我提供的第一个PHP代码只获取所选约会的名称。第二个代码提供了所有约会。我附上了一些希望证明有用的截图。

如何才能获得lep与第一个代码中的lep相同的约会?

<?php
    require "id.php";
    require "calendarconnect.php";

        //MySqli Select Query
        $query = $mysqli->query("SELECT lep FROM appointments WHERE ID = $contactid");

            while ($line = mysqli_fetch_array($query, MYSQL_ASSOC)) {

            echo $line['lep'];}

    require "freeclose.php";
?>


<?php

        require "calendarconnect.php";

    //MySqli Select Query

    $query = $mysqli->query("SELECT ID, appointmentdate, appointmenttime, nature, doctorname, lep FROM appointments ORDER BY appointmentdate");

    print '<table cellpadding="10" cellspacing="3" border="1" class="sortable">';
    print '<tr><th>Date/Time</th><th>Nature</th><th>Doctor Name</th><th>Actions</th></tr>';
    while($row = $query->fetch_assoc()) {
        print '<tr>';
        print "<td>" . date("m-d-y", strtotime($row['appointmentdate'])) . "&nbsp;"  .date( "g:i A",strtotime($row['appointmenttime'] )). "</td>";
        print '<td>'.$row["nature"].'</td>';
        print '<td>'.$row["doctorname"].'</td>';
        print "<td><a href=\"index.php?option=com_content&view=article&id=18&cd=" . $row['ID'] . "\">Edit&nbsp;|&nbsp;</a>";
print "<a href=\"appointmentdelete.php?id=" . $row['ID'] . "\"onclick=
      \"return confirm('Are you sure you want to delete?')\">Delete</a></td>";
        print '</tr>';
    }  
    print '</table>';

    require "freeclose.php";
?>

Appointment

Appointment's from form

LEP

0 个答案:

没有答案