Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: open
I will be really thankful for any help in logic or code.
Note. All this thing will be displayed on password protected page accessible only to admin.
$sql = "select * from table_name where date >= DATE_SUB(NOW(), INTERVAL 1 DAY)";
Here is your select menu:
<option value="0 DAY">Today</option>
<option value="1 DAY">Yesterday</option>
<option value="1 MONTH">Last month</option>
<option value="30 YEAR">All time</option>
Than your query will be:
$sql = "select * from table_name where date >= DATE_SUB(NOW(), INTERVAL ".$_POST['selected_interval'].")";
I did not tested this code, but I think this is a good start point.
$result = mysql_query('SELECT * FROM `table_name` WHERE 'date' >= $from_date AND 'date' <= $to_date ORDER BY `date` DESC');
so i just have to pass values of variables $to_date and $from _date.
but getting error, so just help me with these code.
$result = mysql_query("SELECT * FROM table_name WHERE date >= " . $from_date . " AND date <= " . $to_date . " ORDER BY date DESC");
I think your problems arise from your interchanging of ' and `. You can avoid those errors by concatenating strings as I did in the revised SQL statement.