dongsheng8158 2016-08-09 07:51
浏览 9
已采纳

使用锚标签发送id到php中的下一页

I am showing a html table which is retrieving the data from mysql using php,the table has a column feedback, the elements in this column are hyperlinked, they direct you to program called feedback.php where a feedback form is there with candidate name and id retrieved from database and shown there , below is the code showing the data displayed on table page

echo " <header class='w3-container w3-black'>
      <h1>TABLE Of Faculty Position Applicants :-</h1>
    </header>
     <form action = '' method = 'post'>   
    <table class ='w3-table w3-striped w3-border'>
    <tr class ='w3-grey'>
    <th>Candidate No </th><th>Candidate Name</th><th>Google Scholar</th><th>DBLP</th><th>CV</th><th>Feedback</th>
    </tr>";
    while($row = mysqli_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['candidate_no'] . "</td>";
    echo "<td>" . $row['candidate_name'] . "</td>";
    echo "<td><a href=" . $row['gs_link'] . " target='_blank'>Google Scholar</a></td>";
    echo "<td><a href=" . $row['dblp_link'] . " target='_blank'>DBLP link</a></td>";
    echo "<td><a href=" . $row['cv_link'] . " target='_blank'>CV</a></td>";
    echo "<td><a href=" . $row['feedback_link'] ."  id = ".$row[id]. "  target='_blank'>Feedback</a></td>";
    echo "</tr>";
    }
    echo "</table>";
    echo "</form>";

now you can see this line :-

echo "<td><a href=" . $row['feedback_link'] ."  id = ".$row[id]. "  target='_blank'>Feedback</a></td>";

which I am using to pass the id to feedback.php

on feedback.php this query is written which requires id and retrieved id of the specific candidate using id which is passed to this page

$query="SELECT candidate_name FROM faculty WHERE id=$_POST[id]";
$query2="SELECT candidate_no FROM faculty WHERE id=$_POST[id]";
$result = mysqli_query($conn,$query);
$result1 = mysqli_query($conn,$query2);
$row=  mysqli_fetch_assoc($result);
$row2=  mysqli_fetch_assoc($result1);
$conn->close();

I want to know the way to pass id to feedback.php so that I can retrieve candidate name and id on that program and show it in form which I will display because in above program I am doing some mistakes or is using wrong way to pass the id to feedback.php , please help me if there is problem I will clarify , help me.

  • 写回答

3条回答 默认 最新

  • douyou1857 2016-08-09 07:55
    关注

    You can pass the id as a GET variable, making a link something like this:

    feedback.php?id=123
    

    Then on feedback.php you can catch the ID by using $_GET['id'] where id is the name of the variable and the return will be whatever is set in it, in our example it will be ID 123.

    You can then run your query on these IDs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器