Created
January 20, 2016 03:33
-
-
Save amin007/47f1257572a89f8bc08c to your computer and use it in GitHub Desktop.
papar sql berasaskan bulan dan tahun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="GET" action="searchdate.php"> | |
search by Year <select id="year" name="year"> | |
<option value="">All</option> | |
<?php | |
for($i=2015;$i < date("Y")+1; $i++) | |
{ | |
echo '<option value="'.$i.'">'.$i.'</option>'; | |
} | |
?> | |
</select><input type="submit" value="submit" name="submit"> | |
search by Month <select id="month" name="month"> | |
<option value=""></option> | |
<option value="1">1</option> | |
<option value="2">2</option> | |
<option value="3">3</option> | |
<option value="4">4</option> | |
<option value="5">5</option> | |
<option value="6">6</option> | |
<option value="7">7</option> | |
<option value="8">8</option> | |
<option value="9">9</option> | |
<option value="10">10</option> | |
<option value="11">11</option> | |
<option value="12">12</option> | |
</select> | |
<input type="submit" value="submit" name="submit"> | |
</form> | |
<?php | |
if (isset($_GET['year'])) | |
{ | |
$year = isset($_GET['year']) ? $_GET['year'] : ''; | |
$month = isset($_GET['month']) ? $_GET['month'] : ''; | |
$sql = "SELECT * FROM sales | |
WHERE YEAR(date) = '$year' | |
AND MONTH(date) = '$month' "; | |
echo $sql; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment