我是一個PHP新手,我一直試圖解決這個問題,但無濟於事,我的代碼從頁面獲取'id'並打開一個新頁面,我使用if(isset)_GET方法在新頁面中調用id,並且同時想要連接兩個表以從同一頁面上選擇數據並同時顯示。我寫了下面與if(isset)和連接表呼叫id的問題
代碼,請我會感激,如果有人給我看了我在哪裏錯了,如何做到這一點
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<body class="home">
<!-- Intro -->
<div class="container text-center">
</div>
<!-- /Intro-->
<?php
require_once 'includes/connect.php';
if(isset($_GET['id'])) {
$full_name = $_GET['id'];
$select_query = "SELECT quoteform.quote_id, quoteform.gender, quoteform.feedback_bad, quoteform.feedback_ok, quoteform.size, quoteform.accessory,quoteform.quantity, quoteform.full_name, quoteform.phone_number, quoteform.email, quoteform.location, quoteform.quote_date,quoteform.order_number, price_products.price_withfabric FROM quoteform, price_products WHERE qouteform.feedback_bad = price_products.product_name OR quoteform.feedback_ok = price_products.product_name AND full_name='$full_name' LIMIT 1";
$run_query = mysqli_query($con, $select_query);
?>
<!-- Highlights - jumbotron -order -->
<div class="jumbotron-order">
<div class="container">
<?php
if(mysqli_num_rows($run_query) > 0)
{
while($row = mysqli_fetch_array($run_query))
{
?>
<h3 class="text-center thin"> - Order Form - </h3></br>
<h4 class=" thin"> Hello <?php echo $row["full_name"];?></h4></br>
<h4 class=" thin"> Order No. <?php echo $row["order_name"];?> </h4>
<div class="row">
<div class="col-md-8 col-sm-8">
<div class=" panel">
<table class="table">
<tr>
<th scope="row"> Outfit</th>
<th><?php echo $row["feedback_bad"];?> </th>
</tr>
<tr>
<th scope="row"> Size</th>
<th><?php echo $row["size"];?></th>
</tr>
<tr>
<th scope="row"> Price </th>
<th> <?php echo $quantity; ?> X <?php echo $price_withfabric; ?> </th>
<th> = Amount</th>
</tr>
<tr>
<th scope="row"> Accessory <<- Add More Button ->> </th>
</tr>
<tr>
<td scope="row"> <?php echo $accessory; ?> </td>
<th> Qty X price = </th>
<th> = Amount</th>
</tr>
<tr>
<th scope="row"> Click to select Service Charge </th>
<th> Display Service Name </th>
<th> = Amount</th>
</tr>
<tr>
<th scope="row"> Click to select Delivery </th>
<th> Display Delivery </th>
<th> = Amount</th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> Total </th>
<th> Display Amount Here!!!</th>
</tr>
<tr>
<th scope="row"> Do you have a Coupon Code? </th>
<th scope="row"> coupon input space </th>
<th> The amount to be deducted from Total</th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> Amount to be Charged </th>
<th> Display Amount Here!!!</th>
</tr>
</table>
<div class="text-center"><button class="btn btn-success btn-lg">Preview and Pay</button> <button class="btn btn-danger btn-lg">Cancel Order</button></div>
</div>
</div>
</div>
<!-- /row -->
<?php } } ?>
</div>
</div>
<?php } ?>
你的問題是設計不當。無論如何,該消息意味着你可能在查詢中有錯誤。請訪問[我如何問一個好問題?](https://stackoverflow.com/help/how-to-ask) – FirstOne
謝謝,我剛剛編輯的腳本給我頭痛的問題 – user3619935
**警告**:當使用'mysqli'時,你應該使用[參數化查詢](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)和['bind_param'](http://php.net) /manual/en/mysqli-stmt.bind-param.php)將用戶數據添加到您的查詢。 **不要**使用字符串插值或連接來完成此操作,因爲您創建了嚴重的[SQL注入漏洞](http://bobby-tables.com/)。 **不要**將'$ _POST','$ _GET'或**任何**用戶數據直接放入查詢中,如果有人試圖利用您的錯誤,這可能會非常有害。 – tadman