narendra narendra - 10 months ago 25
MySQL Question

How to get values from database from current date to last 5 days

Get the values from database dynamically. Here is my database

Database Image

And Here is my code

<form method="post" action="" align="center" style="margin-top:50px;">
<select id="date" name="date">
<option>Last 6 days</option>
<option>Last 2 days</option>
<input type="submit" name="submit" value="Submit">
$sql="select value from sort";
echo $row['value'];

I want when i click on last 6 days shows current date to last 6 days values and when i click on last 4 days shows current date to last 4 days values. How to solve dynamically.


"select value from sort where (DATEDIFF(CURDATE(),date)<=6)" or

"select value from sort where  (DATEDIFF(CURDATE(),date)<=4)"

and so on...