上顯示我不能顯示我的搜索表單,我懷疑問題是由於我不工作的複選框。我點擊搜索,它包含任何錯誤,但空白表。也許有可能是一些PHP和SQL語法錯誤,我忽略了。 FYI形式是的index.php如何使多個複選框搜索值的數據庫和
index.php
<?php require_once('Connections/conn.php'); ?>
<!DOCTYPE html>
<html>
<head>
<title>Casado</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/kahwin/index.php">Casado</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</div>
</nav>
<div class="container text-center">
<div class="page-header">
<div class="container">
<form method="post">
<div class="form-group">
<h3><label for="usr">Carian bajet anda:</label></h3>
<div class= "col-md-12">
<div class=" col-md-4"></div>
<div class=" col-md-4">
<input name="bajet" type="text" class="form-control" id="usr"></div>
</div>
<div class=" col-md-4"></div>
</div><br>
<h3><label for="sel1">Pilih negeri pilihan anda:</label></h3>
<div class= "col-md-12">
<div class=" col-md-4"></div>
<div class=" col-md-4">
<select class="form-control" name="sel">
<option>Kuala Lumpur</option>
<option>Negeri Sembilan</option>
<option>Pahang</option>
<option>Perak</option>
<option>Terengganu</option>
<option>Selangor</option>
</select>
</div>
<div class=" col-md-4"></div>
</div><br>
<br>
<h5><label for="check">Senarai Pra-perkahwinan:</label></h5>
<center> <div class="checkbox">
<label class="checkbox-inline"> <input type="checkbox"name="check_list[]" value="Jurufoto"><label>Jurufoto</label></label>
<label class="checkbox-inline"> <input type="checkbox"name="check_list[]" value="Butik"><label>Butik</label></label>
<label class="checkbox-inline"> <input type="checkbox"name="check_list[]" value="Hiburan"><label>Hiburan</label></label>
<label class="checkbox-inline"> <input type="checkbox"name="check_list[]" value="Kad Kahwin"><label>Kad Kahwin</label></label>
<label class="checkbox-inline"> <input type="checkbox"name="check_list[]" value="Katering"><label>Katering</label></label>
<br>
</center>
<div class="col-md-4"></div>
<div class="col-md-4">
<button class="btn btn-success btn-sm" name="search">Search <span class="glyphicon glyphicon-search"></span></button><br><br>
</div>
<div class="col-md-4"></div>
</div>
</form>
<table class="table table-bordered">
<thead>
<tr>
<th>Jenis</th>
<th>Vendor</th>
<th>Negeri</th>
<th>No.</th>
<th>Pakej</th>
<th>Harga</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$budget = $_POST['bajet'];
$select = $_POST['sel'];
$check = $_POST['check_list'];
if (isset($_POST['search'])) {
mysql_select_db($database_conn, $conn);
$sql = mysql_query(" SELECT *
FROM vendor
RIGHT JOIN item
ON vendor.v_id=item.v_id
WHERE item.harga <= ' $budget '
AND vendor.state = ' $select '
AND vendor.type = ' $check ');
while($row = mysql_fetch_array($sql)) {
?>
<tr>
<td><?php echo $row['type'] ?></td>
<td><?php echo $row['companyName'] ?></td>
<td><?php echo $row['state'] ?></td>
<td><?php echo $row['contact'] ?></td>
<td><?php echo $row['harga'] ?></td>
<td><?php echo $row['pakej'] ?></td>
<td><a href="index.php?v_id=<?php echo $row['v_id']?>">View Package</a></td>
</tr>
<?php }
}
?>
</tbody>
</table>
</div>
的HTML看起來雜亂無章,似乎有些標籤沒有被關閉,可能導致問題的 – kaklon