如何通过链接将数据从一个页面传输到另一个页面?

时间:2018-03-16 10:00:58

标签: php html mysql

enter image description here我有一个数据库和一个名为Teacher's_request_display.php的页面,它显示了来自它的数据(你可以在下面看到它的图像)。 我想要做的是点击一个随机行(特别是在描述部分,这是最大的单元格),这样它就会将我转移到另一个页面,Teacher's_request_detailed.php这个页面应该显示有关这个工作的信息,在Teacher's_request_display.php中无法看到的信息,这意味着它必须连接到数据库。

我应该怎么做才能让Teacher's_request_detailed.php收到正确的数据(点击的数据)?我可以在phpmyadmin中为我的表添加一个“ID”列,以便区分请求,但是Teacher's_request_detailed.php如何检测它并连接到数据库中的右行?

我在下面附上了Teacher's_request_display.php。 Teacher's_request_detailed.php并不重要,它只是显示信息。

<?php
  include_once 'Connection.php';
?>


 <!DOCTYPE html>
<html>
<head>
    <title>Display</title>
    <link rel = "stylesheet" type = "text/css" href = "Display_style.css">
</head>



<body>
    <script src = "Myscript.js"></script>
    <h1 style = "text-align: center;">Существующие работы   </h1>
    <p style = "text-align: left;">Сортировка</p> 
    <button onclick = "SortByPayment()">Оплата</button>
    <button onclick = "SortByPeople()">Люди</button>
    <button onclick = "SortByUrgency()">Срочность</button>
    <button onclick = "SortByDifficulty()">Сложность</button>
        <br> <br> <br>
<table style = "width:100%">
    <tr>
        <th style = "width:13%">Работодатель</th>   
        <th>Описание работы</th>
        <th style = "width:8%">Оплата</th>
        <th style = "width:8%">Количество людей</th>
        <th style = "width:10%">Срочность</th>
        <th style = "width:8%">Сложность</th>       
    </tr>
</table>


<?php
  $sql = "SELECT * FROM trequests;";
  $conn = Connect();
  mysqli_set_charset($conn,'utf8');
  $result = mysqli_query($conn, $sql);  //<td style = "width:13%">'.$row['ID'].'</td>
  $resultCheck = mysqli_num_rows($result);  
  echo '<table style = "width:100%"; id = "All_Trequests">';
  if ($resultCheck > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        echo "  <tr>
                  <td style = \"width:13%\">".$row['Customer']."</td>
                  <td class = \"job-style\" title = \"".$row['The_Job']."\"
                  onclick = \"location.href = 'Teacher's_request_detailed.php'\">
                  <a href = \"Teacher's_request_detailed.php\">"
                  .$row['The_Job']."</a></td>
                  <td style = \"width:8%\">".$row['Paymentfro']."-".$row['Paymentto']."</td>
                  <td style = \"width:8%\">".$row['Amount']."</td>
                  <td style = \"width:10%\">".$row['Urgency']."</td>
                  <td style = \"width:8%\">".$row['Difficulty']."</td>      
                </tr>";

    }
  echo '</table>';  
  }

?>



</body>

</html>

0 个答案:

没有答案