亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

自動獲取數據庫值,而無需用戶輸入

自動獲取數據庫值,而無需用戶輸入

PHP
慕容森 2021-05-07 14:16:28
我正在制作一個頁面,該頁面將獲取我的所有數據庫值。我希望頁面從數據庫自動獲取Driver_id和Vehicle_id的值,用戶需要知道自己的ID和密鑰是什么。但是我被困在這里。我正在使用的工具是phpMyAdmin。下面是我的表格代碼:<!doctype html><html><style><table>    <th>Vehicle ID</th>    <th>Vehicle Model</th>    <th>Vehicle Color</th>    <th>Plate Number</th>    <th>Seats</th>    <th>Driver ID</th>    <th> </th><?php     $link=mysqli_connect("localhost","root","","jomsewa");    mysqli_select_db($link,"jomsewa") or die(mysqli_error($link));    $select = "SELECT * FROM vehicle";    $row = mysqli_query($link,$select);    while ($array = mysqli_fetch_array($row)){        echo "<tr><td>".$array['Vehicle_id']."</td>                    <td>".$array['Vehicle_model']."</td>                    <td>".$array['Vehicle_color']."</td>                    <td>".$array['Vehicle_model']."</td>                    <td>".$array['Vehicle_seats']."</td>                    <td>".$array['Driver_id']."</td>                    <td><a href='Dmaintenance.php?Driverid=".$array['Driver_id']."'>Select</a></td>"."</tr>";    }    mysqli_close($link);?></table></body></html>鏈接鏈接到Dmaintenance.php:<?php$link=mysqli_connect("localhost","root","","jomsewa"); if (!$link) { echo "Failed to connect to database: " . mysqli_connect_error(); }mysqli_select_db($link,"jomsewa") or die(mysqli_error($link));?><h3>Please update your maintenance details in the form below.</h3><form action="maintenance.php" method="post"><fieldset>    <legend>Vehicle Maintenance Information:</legend>    <table cellpadding="10">    <tr>        <td>                <?php         if(isset($GET['Driver_id']))                 {           $txt = $GET['Driver_id'];           while($row = mysqli_fetch_array($result))                 {            echo "<td>".$row['Vehicle_id']."</td>";            echo "<td>".$row['Driver_id']."</td>";             }            }?></td>       </tr>我想要的是,當單擊下一頁上的一個特定行鏈接時,它必須自動顯示我選擇的行內容。
查看完整描述

2 回答

?
瀟湘沐

TA貢獻1816條經驗 獲得超6個贊

使用$_GET['Driverid]代替$_GET['Driver_id]


沒有SQL查詢Dmaintenance.php可獲取基于的行Driverid。應該有


$query = "SELECT * FROM vehicle WHERE Vehicle_id=".$_GET['Driverid'];

$row = mysqli_query($link,$query);


while ($array = mysqli_fetch_array($row)){

  print_r($array);

}

例如


<a href="Dmaintenance.php?Driverid=123">Click Here</a>

并且僅在中使用following Dmaintenance.php,您將看到參數值


if(isset($_GET['Driverid'])){

 echo $_GET['Driverid'];

}


查看完整回答
反對 回復 2021-05-21
  • 2 回答
  • 0 關注
  • 156 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號