daredavil07
Addict
- Joined
- Aug 24, 2018
- Posts
- 63
- Reaction
- 17
- Points
- 83
Hello po, sinusubukan ko pong kumuha ng content sa db ko na pasok sa date range na napili ko sa datepicker(s) at display sa table. Ano po kaya yung mali sa query ko?
Ito po yung db ko:
Salamat po!
Code:
<html lang="en">
<head>
<title>List</title>
<script src="jquery-3.3.1.min.js"></script>
<script src="jquery.min.js"></script>
<script src="jquery-ui.js"></script>
<link href="jquery-ui.css" rel="stylesheet"/>
<link rel="stylesheet" href="jquery-ui.css">
</head>
<body>
<h1 align="center">List</h1>
<center><form><p class="search_input">
<input type="text" placeholder="From Date" id="from" name="from" />
<input type="text" placeholder="To Date" id="to" name="to" />
<input type="submit" name="go" value="Search" />
</p></form></center>
<table align="center" cellspacing="0" cellpadding="0">
<thead class="fixedthead">
<th width="120px" style="text-align: center; color: navy">Name</th>
<th width="120px" style="text-align: center; color: navy">Description</th>
<th width="120px" style="text-align: center; color: navy">Date</th>
<th width="120px" style="text-align: center; color: navy">Open</th>
</thead>
<?php
error_reporting(0);
$from = $_POST['from'];
$to = $_POST['to'];
$conn = mysqli_connect("localhost", "root", "", "order");
$result = mysqli_query($conn, "SELECT * FROM item WHERE date between '$from' AND '$to' ", MYSQLI_USE_RESULT) or die(mysqli_error($conn));
while($row = mysqli_fetch_array( $result )) {
?>
<tbody>
<tr>
<td width="120px" style="text-align: center"><?php echo $row['name']; ?></td>
<td width="120px" style="text-align: center"><?php echo $row['description']; ?></td>
<td width="120px" style="text-align: center"><?php echo $row['date']; ?></td>
<td width="120px"><a href = "download.php?id=<?php echo $row['id']; ?>" ><button>Open</button></a></td>
</tr>
</tbody>
</table>
<?php
}
?>
</body>
</html>
<script type="text/javascript">
var dateToday = new Date();
var dates = $("#from, #to").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 2,
onSelect: function(selectedDate) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $(this).data("datepicker"),
date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
}
});
</script>
Ito po yung db ko:
Salamat po!
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.