我想根据用户给定的输入做搜索选项,并且应该显示匹配记录和给定标准。下面是我的代码。
<?php
if(isset($_POST['search'])){
echo "<script> document.getElementById('tblsearch').style.display = 'block' </script> ";
$serviceNumber='52805';
$pendingfrom=$_POST['pendingfrom'];
$status=$_POST['status'];
$datefrom=$_POST['datefrom'];
$dateto=$_POST['dateto'];
$searchkey='serviceNumber';
$sql = 'SELECT * FROM user WHERE ';
$where = array();
$values = array();
$types = '';
if (!empty($_POST['name'])) {
$where[] = 'Username = ?';
$values[] = $_POST['name'];
$types .= 's';
}
if (!empty($_POST['status'])) {
$where[] = 'status = ?';
$values[] = $_POST['status'];
$types .= 's';
}
$sql .= implode(' AND ',$where);
$sth = $dbcon->prepare($sql);
$sth->bind_param('ss',$name,$status);
$sth->execute();
$result=$sth->store_result();
?>
<tr>
<td><?php echo ?></td>
<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data">
<td><button type="submit" class="btn btn-primary btn-block" name="view" id="view" value="<?php echo $row['rid'] ?>">View</button></td>
</form>
</tr>
<?php
}
?>
所以我需要逐列获取记录详细信息并将其设置为表格
我已将结果存储到$ result变量中
之后,我需要逐列获取数据。
如果有人能提供帮助,我们表示赞赏。