I am an absolute newbie and still working out the kinks. So spare me if the code looks amateurish.
I have this form.html
The user enters the date range.
form action="report.php" method="post"
FROM DATE <input type="DATE" class="textarea" name="dateStart"><br> </br>
TO DATE <input type="DATE" class="textarea" name="dateEnd">
<input type="submit" class="textarea">
</form>
This gets processed in Report.php now report.php looks like this:
php
$_POST["dater"]=$date;
$con=mysqli_connect("LOCALHOST","xxxxxxx","xxxxxx","xxxxx");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM `xxxxxxx`
dater);
echo "<table border='1'>
<tr>
<th>DATE</th>
<th>MBM</th>
<th>bulkTank</th>
<th>bagsAt40</th>
";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['bulkTank'] . "</td>";
echo "<td>" . $row['bagsAt40'] . "</td>";
echo "</tr>";
}
echo "</table>";
I have no clue what to do next.... its not working, i tried a few things but how can I echo the result within a specific date range. Thanks!
New edit ---- This is what the new code looks like... Form START DATE
END DATE
Report.php
<?php
$date=$_POST["dateStart"];
$con=mysqli_connect("LOCALHOST","XXXXXXX","++++++","XXXXXX");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM `WeeklyStockTake`
WHERE dateColumn=$date);
echo "<table border='1'> <!--line 32 starts here--!>
<tr>
<th>DATE</th>
<th>MBM</th>
<th>bulkTank</th>
<th>bagsAt40</th>
-----If I process it now I get this error - Parse error: syntax error, unexpected T_STRING in /home/simples2/public_html/test/report.php on line 32 (I have commented above as to where it starts) How to I declare the end date?
Thanks and regards!
Dont know if its a typo but php should be <?php
$_POST["dater"]=$date
This should be
$date=$_POST["dateStart"]
Also you should add a POST for dateEnd also
The query should be more like:
SELECT * FROM `xxxxxxx` WHERE dateColumn<=$date