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条)

报告相同问题?

悬赏问题

  • ¥15 表达式必须是可修改的左值
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题