這是search.php
代碼:(這一部分,我將搜索關鍵字,然後顯示到retrievecustomerinfo.php
)檢索信息並在另一個頁面選擇信息彈出
<?php
$strKeyword = NULL;
?>
<body>
<div align="center">
<form name="frmSearch" method="post" action="retrievecustomerinfo.php">
<table >
<tr>
<th>Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<?php echo $strKeyword; ?>">
<input type="submit" value="Search">
</th>
</tr>
</table>
<br>
</form>
</div>
</body>
這是retrievecustomerinfo.php
代碼:(此頁面會顯示結果哪些用戶需要的信息)
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$strKeyword = NULL;
if (isset($_POST["txtKeyword"])) {
$strKeyword = $_POST["txtKeyword"];
}
$sql = "SELECT * FROM customer_info WHERE cust_ic LIKE '%" . $strKeyword . "%' OR cust_hp_contact1 LIKE '%" . $strKeyword ."%' OR cust_name LIKE '%" . $strKeyword . "%' limit {$start} , {$perpage}";
$query = mysqli_query($conn, $sql);
?>
<form name="retrieve" action="topuppage.php" method="post">
<table class="table table-hover" >
<thead>
<tr>
<th>Number</th>
<th>Name</th>
<th>State</th>
<th>Contact Number</th>
<th>Action</th>
</tr>
</thead>
<?php
$no = 1;
while ($result = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
?>
<tr>
<td><?php echo $no ?></td>
<td><?php echo $result['cust_name'] ?></td>
<td><?php echo $result['cust_state'] ?></td>
<td><?php echo $result['cust_hp_contact1'] ?>
<?php echo $result['cust_hp_contact2'] ?></td>
<td>
<button type="submit" name="cust_name" value="<?php echo $result['cust_name'] ;?>"
name="cust_hp_contact1" value="<?php echo $result['cust_hp_contact1'] ;?>" class="btn btn-link">SELECT</button>
</td>
</tr>
<?php
$no++;
}
?>
</table>
<?php
mysqli_close($conn);
?>
這是topuppage
代碼:(即用戶在retrievecustomerinfo.php
選擇此頁面將顯示值)
<form name="getdata" method="get">
<div>
<h5>TAG THIS SALE ORDER TO THE FOLLOWING CUSTOMER</h5>
<div class="col-xs-3">
<label for="cname">Contact Name</label>
<input type="text" class="form-control input-sm" id="cname"
value="
<?php
if(isset($_POST['cust_name']))
{
echo $_POST['cust_name'];
}
?> ">
<label for="cno">Contact Number</label>
<input type="text" class="form-control input-sm" id="cno"
value="
<?php
if(isset($_POST['cust_hp_contact1']))
{
echo $_POST['cust_hp_contact1'];
}
?> ">
<p></p>
<button type="reset" class="btn btn-default">Clear</button>
</div>
</div>
</form>
如何從retrievecustomerinfo.php
獲得價值併發布到topuppage.php
的文本框中應該是聯繫人姓名和聯繫電話號碼?
這個輸出我點擊我得到這樣的結果: i.gyazo.com/455468f3b83bee81d5c2766d711c72b2.png –
您是否添加了這一行:」/>'radio按鈕應該有元素名稱'name =「cust_name」'AND,並提交表格 – Ruprit
是的,結果是可以在文本框中彈出,但在檢索數據之前出錯。 –