dongpu1881 2016-05-06 18:19
浏览 36

PHP链接与SQL数据库

New to PHP here. I'm working on a basic PHP project for university. I have a page with a list of patients. When you click on the patient it will take you to the patient page with more details of that patient.

I have a main patientDetails.php page which will display the details.

However I am a little puzzled. How do I get the "?Name.." part of the link to work. So how do I get the patientDetails page to load the specific patient details?

I have an index.php page which has the list of patients as below.

<td><a href="patientDetails.php?Name=Stuart">Stuart</a></td></tr><tr>    <td>2</td>
   <td><a href="patientDetails.php?Name=Fred">Fred</a></td></tr><tr>

In the PatientDetails page I have a select statement to gather details from the Database but not sure where else to go from here.

   $query = sprintf("select * from PHPEnrolment WHERE PatID = '$PatID' AND NAME     = '$Name' AND Email = '$Email'");
 $result = mysql_query($query, $link);
    if ($result) {
  while($row = mysql_fetch_array($result)) {

  }

As you can see above the database table with patients has the PatID, Name and Email field.

Thanks

PLEASE NOTE: This is a basic project that I am working on, so I am aware some of the features are outdated but I need to get it working with these features if possible.

  • 写回答

2条回答 默认 最新

  • dourui9570 2016-05-06 18:22
    关注

    As per your code there are several errors. and for getting value you can use $_GET['Name']. I am assuming that you have all other variables($Email and $PatID)

    $Name = $_GET['Name'];
    

    Your query is not right. Change it from

    select * from PHPEnrolment WHERE PatID = '$PatID' AND $NAME = 'Name' AND Email $Email
    

    To

    select * from PHPEnrolment WHERE PatID = '$PatID' AND NAME = '$Name' AND Email = '$Email'
    

    So your whole code should look like.

    $query = "select * from PHPEnrolment WHERE PatID = '$PatID' AND NAME = '$Name' AND Email = '$Email'";
    $result = mysql_query($query, $link);
    

    NOTE : STOP USING MYSQL. It is deprecated now.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题