gpt4 book ai didi

php - 数据表的组合框 MySQL 过滤器

转载 作者:行者123 更新时间:2023-11-30 22:19:06 26 4
gpt4 key购买 nike

试图让我的数据表通过组合框进行过滤。不知道为什么它不回发结果。它在 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>

最佳答案

不确定 header.php 文件指的是什么。是包含表格的文件吗?

在这种情况下,请确保您加载的是带有数据库连接和 sql 的 PHP 页面,而不是网络浏览器中的 header.php 文件。

这样,首先数据库 $result 被初始化,然后数据通过循环输入到表中。

希望这对您有所帮助。

关于php - 数据表的组合框 MySQL 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37233541/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com