<?php
echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";
echo "<td width='100' align='center'>date in</td><td width='100' align='center'>date out</td>
<td width='100' align='center'>model</td>
";
echo "</tr>";
include("proses/dbcon.php");
$date_in = $_POST['date_in'];
$date_out = $_POST['date_out'];
if(isset($submit))
{
$sql = "select * from inventory where createdate >= '$date_in' and createdate <= '$date_out' ";
}
$result= mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td align='center' width='200'>" . $row['date_in'] . "</td>";
echo "<td align='center' width='200'>" . $row['date_out'] . "</td>";
echo "<td align='center' width='200'>" . $row['model'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
muhamadtaufiq.zaki
0
Newbie Poster
Recommended Answers
Jump to PostYou have to initialize the variables: if
$submit
is not set then$sql
is not initialized and the query will fail.Also for the query you can use the
column BETWEEN value AND value
condition. So change your code to:$submit = $_POST['submit']; # …
Jump to PostA few things.
1) Try to avoid mixing html/php wherever possible.
2) Use mysqli/PDO instead of mysql.
3) Don't echo every little thing. Instead concatenate your output and make one echo.
All 8 Replies
muhamadtaufiq.zaki
0
Newbie Poster
network18
15
Practically a Master Poster
cereal
1,524
Nearly a Senior Poster
Featured Poster
kaleemullah360
0
Newbie Poster

diafol
muhamadtaufiq.zaki
0
Newbie Poster
cereal
1,524
Nearly a Senior Poster
Featured Poster
muhamadtaufiq.zaki
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.