尝试让我的数据表通过组合框进行过滤。不知道为什么它没有回复结果。它在phpMyAdmin
中查询设置为下拉框的值,这些值是将数据提取到下面的表格所必需的。
无法在提交的数据表中显示数据。对不起我是新来的,每天都在学习!不知道为什么它没有出现。谢谢你花时间给他。
PHP代码:
<?php
// connect to database
include('includes/connection.php');
// query & result
$query = "SELECT timestamp, DATE_FORMAT( timestamp + INTERVAL 3 HOUR, '%m-%d-%Y %r') AS formatted_ts, timestamp, marketer, facility, name, type, phone, email, fax, description, locality, state, zip, latlng FROM leads WHERE marketer = '".$marketeer."' ORDER BY timestamp DESC ";
$result = mysqli_query( $conn, $query );
// query & result
/*$query = "SELECT DATE_ADD(timestamp, INTERVAL 3 HOUR), timestamp, marketer, facility, name, type, description, locality, state, zip, latlng FROM leads WHERE marketer <> 'Tommy' AND DATE(`timestamp`) = CURDATE()
ORDER BY DATE_ADD(timestamp, INTERVAL 3 HOUR) DESC";
$result = mysqli_query( $conn, $query );*/
// close the mysql connection
mysqli_close($conn);
include('includes/header.php');
?>
HTML代码:
<div class="col-sm-8 text-left">
<h1>Todays' Marketing Leads<?php echo $row_User['FirstName']; ?> <?php echo $row_User['LastName']; ?>.</h1>
<hr>
<form action="" method="post">
<select name="marketeers">
<option value="Scott">Scott</option>
<option value="Tammy">Tammy</option>
<option value="Joey">Joey</option>
</select>
<input type="submit">
</form>
<hr>
<table border="1">
<?php echo $alertMessage; ?>
<table class="table table-striped table-bordered">
<tr>
<th>Timestamp</th>
<th>Marketer</th>
<th>Facility</th>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Location Mapped</th>
</tr>
<?php
if( mysqli_num_rows($result) > 0 ) {
// we have data!
// output the data
while( $row = mysqli_fetch_assoc($result) ) {
echo "<tr>";
echo "<td>" . $row['DATE_ADD(timestamp, INTERVAL 3 HOUR)'] . "</td><td>" . $row['marketer'] . "</td><td>" . $row['facility'] . "</td><td>" . $row['name'] . "</td><td>" . $row['type'] . "</td><td>" . $row['description'] . "</td><td>" . $row['locality'] . "</td><td>" . $row['state'] . "</td><td>" . $row['zip'] . "</td><td>" . $row['latlng'] . "</td>";
echo "</tr>";
}
} else { // if no entries
echo "<div class='alert alert-warning'>There are no current leads today!</div>";
}
mysqli_close($conn);
?>
</table>
答案 0 :(得分:0)
不确定 header.php 文件是指什么。它是包含表格的文件吗?
在这种情况下,请确保您在Web浏览器中使用数据库连接和sql而不是 header.php 文件加载PHP页面。
这样,初始化第一个数据库$ result,然后通过循环将数据输入表中。
希望这有帮助。