0
하나의 양식 제출의 결과 인 데이터 테이블이 있는데 양식의 유형은 DATETIME-LOCAL
인 start_date 및 end_date입니다. 내 데이터베이스에서날짜가있는 데이터 테이블 검색
는이 DATETIME
,
내가 일하지 날짜와 시간을 기준으로 내 데이터 테이블에 검색 기능을 추가 할,
다른 유형과 (AM과 PM을 표시하지 않음) NAME이 (가) 작동하지만 날짜가 표시되지 않으며 오류 및 결과가 표시되지 않습니다.
<form action="search.php" id="searchform" method="POST" class="searchbox-container">
<input type="text" id="searchbox" placeholder="Search" name="searchbox" class="searchbox" />
<input type="date" name="date">
<select name="select" id="select">
<option value="type">Type</option>
<option value="name">Name</option>
</select>
<input type="submit" name="search" class="searchbox-btn" value="Go" />
</form>
<?php
if(isset($_POST['search'])){
$search=preg_replace('#[^a-z 0-9?!]#i','',$_POST['searchbox']);
$user="admin";
$pass="neehahs";
$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();
}
$date=$_POST['date'];
if($_POST['select']=="type"){
$sqlcommand="SELECT * FROM eventform WHERE event_type LIKE '%$search%'";
}
elseif($_POST['select']=="name"){
$sqlcommand="SELECT * FROM eventform WHERE event_name LIKE '%$search%'";
}
else {
if($date!=0)
$sqlcommand="SELECT * FROM eventform WHERE start_date='$date' ORDER BY start_date DESC";
}
$sqldata=mysqli_query($con,$sqlcommand)
or die("Error Getting Data");
$count=mysqli_num_rows($sqldata);
if($count!=0){
echo "<table border=2 bordercolor=#440000 cellpadding=2 bgcolor=#DDDDDD width=100%>";
echo "<tr bgcolor=#555555 style=font-size:18px align=center><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)){
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 "<a href=http://localhost/greenstudio/".$row['pic'].">".$row['pic']."</a>";
echo "</td><td>";
echo "<a href=http://localhost/greenstudio/".$row['video'].">".$row['video']."</a>";
echo "</td><td>";
echo $row['description'];
echo "</td></tr>";
}
echo "</table>";
}else{
echo "hi";
$search_output="<hr/>0 Results for<strong>$search</strong><hr/>";
}
}
?>