php - change select value when press button -


i'm still beginner @ have table , select data between 2 date range using code , working fine me

$startdate = "2016-01-01"; $enddate =  "2016-12-30"; $result = mysql_query("select *from users submit_date between '$startdate' , '$enddate'") or die(mysql_error()); 

then added 2 data picker , button

echo "<form method=post action=><table>". "<tr><td>start date : </td><td><input type=date name=startdate value=$startdate></td></tr>". "<tr><td>end date : </td><td><input type=date name=enddate value=$enddate></td></tr>". "<tr><td colspan=2><input type=submit name=updateselect value=set></td></tr>". "</table></form>"; 

now need how update page when press sumbit button start selecting new start date , end date.

i'm sorry bad english. , thanks

a small demo of problem hope , solve problem. assume using mysqli connection object.

    if (isset($_post['submit_btn']))     {         $start_date = $_post['start_date'];         $end_date   = $_post['end_date'];         $sql = "select * users submit_date between '$start_date' , '$end_date'";         $result = $conn->query($sql);     }      $conn->close(); ?>  <html> <head>     <title></title> </head> <body>     <form action="" method="post">         <table>             <tr>                 <td><input type="date" name="start_date" value=""/></td>             </tr>             <tr>                 <td><input type="date" name="end_date" value=""/></td>             </tr>             <tr>                 <td><input type="submit" name="submit_btn" value="set"/></td>             </tr>         </table>     </form>      <!-- here data manupulation logic -->     <?php         if (isset($result) && !empty($result))         {             if ($result->num_rows > 0) {                 // output data of each row                 while($row = $result->fetch_assoc()) {                     echo "id: " . $row["id"];. " - name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";                 }             } else {                 echo "0 results";             }         }     ?> </body> </html> 

the used input fields should contain date. depending on browser support, date picker can show in input field.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -