【发布时间】:2018-06-05 21:08:15
【问题描述】:
我的网站中有一个数据表,我想添加搜索功能,这些功能可以基于名称、类型和日期等条件,因为表中的数据与事件有关。
这是我的表格代码:
<?php
$user="admin";
$pass="whatever";
$host="localhost";
$db_name="eventregisteration";
$con=mysqli_connect($host, $user, $pass, $db_name);
if(mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sqlget="SELECT * FROM eventform";
$sqldata=mysqli_query($con,$sqlget)
or die("Error Getting Data");
echo "<table border=2 bordercolor=#440000 cellpadding=2 bgcolor=#DDDDDD width=100%>";
echo "<tr bgcolor=#555555 style=font-size:18px><th>Event Code</th><th>Event Name</th><th>Event Type</th><th>Event Level</th><th>Start Date</th>
<th>End Date</th><th>Point</th><th>Picture</th><th>Video</th><th>Description</th></tr>";
while($row=mysqli_fetch_array($sqldata, MYSQLI_ASSOC)){
echo "<tr align=center><td>";
echo $row['event_code'];
echo "</td><td>";
echo $row['event_name'];
echo "</td><td>";
echo $row['event_type'];
echo "</td><td>";
echo $row['event_level'];
echo "</td><td>";
echo $row['start_date'];
echo "</td><td>";
echo $row['end_date'];
echo "</td><td>";
echo $row['points'];
echo "</td><td>";
echo $row['pic'];
echo "</td><td>";
echo $row['video'];
echo "</td><td>";
echo $row['description'];
echo "</td></tr>";
}
echo "</table>";
?>
我需要一个带有类型、日期、名称和文本框的下拉框,我不知道如何将它们相互连接,所以如果用户想按名称搜索,他们选择名称,如果他们想按日期搜索为他们弹出一个日历。
【问题讨论】:
-
为什么需要这个代码?这是为了正确显示结果
-
其实我需要通过链接显示图片和视频,但我不知道怎么做,你有什么其他的建议吗?
-
你在数据库中只存储文件名吗?你在本地主机上工作。让我知道。
-
我在数据库中存储文件路径,是的,我使用 XAMPP
-
能否提供图片和视频的样例条目。
标签: php mysql html-table