I will like to fetch data base result based on the info I get from a form input. For example I have a calendar and will like to execute a query that provide date range.
<?php
require_once 'init.php';
$base_datos = DB::getInstance();
$from = $_POST["from"];
$to = $_POST["to"];
$run = $_POST["run"];
echo "$from";
echo "$to";
echo "$run";
if ($run == run)
{
$base_datos->query ("
SELECT *
FROM request
WHERE
req_date BETWEEN $from AND '$to '
ORDER BY req_date DESC;");
$get_info = $base_datos->results();
$real_info = $get_info[0];
//var_dump ($get_info);
foreach($get_info as $real_info) {
echo "<ul class='pen_cancel'>";
echo "<a href='admin_user.php?id=$real_info->user_id'>"
echo $real_info->fname. "</a>" ;
echo "<li class='pen_cancel'>" .$real_info->lname. "</li>" ;
echo "<li class='pen_cancel'>" .$real_info->amount. "</li>" ;
echo "<li class='pen_cancel'>" .$real_info->points. "</li>" ;
echo "</ul>";
echo "</br>";
}
}
else {
echo "test is working";
}
?>
On the query if I put date manually it does work, and $from
$to
does echo calendar select dates, how can I make the query display info based on the $_post
info coming from a form, calendar info is in a form input field.