javascript - Passing a variable from one php form to another - current date and time -


let me start off saying (clearly) new web development. trying query mysql database range of time of today's date, have part down if hardcode it. website grab current date each time loaded , display data, have set of drop boxes user can select specific date displaying data. here have far:

on index.php page have:

$result_date = mysqli_query($link, "select date mydata       year(date)='$year'and month(date)='$month' , day(date)='$day'"); 

if use:

$year=date('y'); $month=date('n'); $today = getdate(); $day=$today['mday']; 

on same index.php worked fine, until woke morning , still displaying yesterdays data , not updating today (unless hardcoded 2015, 7, 9) etc.

i have page data.html.php has front-end html stuff have written code drop down menu , submit button, , other graphics website. think need place year, month , day variables on page , pass index.php page, i'm not sure how. here form... ellipses data choices:

<form action=" ">   <select name="month">   <option value="01">jan</option>   ...   </select>   <select name="day">   <option value="1">1</option>   ...   </select>   <select name="year">   <option value="2015">2015</option>   ...   </select>   <input id="viewbtn" type="button" value="view" onclick=" " />  </form> 

so goal have default date used unless user selects different date drop down menu , clicks view. imagine need kind of onclick method, proper form actions , way pass variables, i'm stuck after googling while now. appreciated!

replace form :

<form action="" method="post"> 

and input :

<input id="viewbtn" type="submit" name="submit" value="view" /> 

try add condition :

if(isset($_post['submit'])){       $year=$_post['year'];       $month=$_post['month'];       $today = $_post['day']; }else{       $year=date('y');       $month=date('n');       $today = getdate(); }  $day=$today['mday']-1; 

now default today date , if user submit, new values taken.

hope answers question


Comments