我有一張表應該根據同一行中的選擇檢索數據庫中的所有行。選擇一個選項從數據庫中檢索它的行MySQL&PHP
HTML & PHP代碼
<div class="row">
<div class="table-responsive">
<table class="table table-bordered" id="tab_logic">
<thead>
<tr>
<th>Brand Name</th>
<th>Item Name</th>
<th>Model Number</th>
<th class="col-md-2">Item Description</th>
<th>Part Number</th>
<th>Unit</th>
<th class="col-md-1">QTY</th>
<th class="col-md-1">Unit Price (SR)</th>
<th class="col-md-1">Total Price (SR)</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>Record</strong>
</td>
<td>
<strong>Record</strong>
</td>
<td>
<strong>Record</strong>
</td>
<td>
<div class="form-group">
<?php
$query = $con->query("SELECT products_itemDescription FROM pruc_products"); // Run your query --> For Item Desc.
echo '<select class="form-control" id="DescriptionS2forms" name="itemDescription">'; // Open your drop down box
echo '<option value="" selected="selected" disabled></option>'; //Empty Value for VALIDATION
// Loop through the query results, outputing the options one by one
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
echo '<option value="'.$row['products_itemDescription'].'">'.$row['products_itemDescription'].'</option>';
}
echo '</select>';// Close your drop down box
?>
</div>
</td>
<td>
<strong>Record</strong>
</td>
<td>
<strong>Record</strong>
</td>
<td>
<div>
<input class="form-control" type="number" name="requestQTY" required>
</div>
</td>
<td>
<div>
<input class="form-control" type="number" name="requestUnit" step="0.01" min="0.01" max="1000000" required>
</div>
</td>
<td>
<strong>Record</strong>
</td>
<td class="col-md-1" id="deleteBtn">
<a class="btn btn-default deleteBtn">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
所以我定義它這個選擇是獲取從數據庫中,所以我需要每一個「記錄」,但也獲取基礎上,選擇我」將從選擇標籤中製作。
PHP & SQL查詢
<?php
$sql = $con->prepare("SELECT products_brandName FROM pruc_products WHERE products_brandName, products_itemDescription = (products_id)") ;
$sql->execute() ;
while($row = $sql->fetch()):
echo '<strong>'.$row['products_brandName'].'</strong>';
endwhile ?>
這方面的任何幫助嗎?
問問自己。這是正確的方式使用**在哪裏條款**在「* .. WHERE products_brandName,products_itemDescription = *」? –
但是我知道這是錯的我正在嘗試 你有更好的評論? –