How to make a data output on the page?

Select the date for which you want to display posts:
<form method="post" name="delivery_date" action="date.php">
<input class="form-control" type="date" name="delivery_date" value="" id="example-date-input"> <button type="submit" class="btn btn-primary btn-xs mb-3">Find</button>
</form>

Processed incoming date and do a dB query to output the desired positions.
<?php

require_once('db.php');

if(isset($_POST['delivery_date']))
{
 $date = $_POST['delivery_date'];
 $SQL = "SELECT * FROM $dbtable WHERE delivery_date='$date' AND delivery='1' ORDER BY id DESC";
 $result = mysqli_query($link, $SQL);

 while ($res = mysqli_fetch_assoc($result)) {
 printf ("%s\n", $res["delivery_date"]);
}
}
?>


And...nothing happens, blank page. Please explain what I'm doing wrong. Ideally, I would like to display just the data in a column (somehow). Ie first array of data with id=3, then id=2, etc. I first tried to do it through the function, but I messed up bad, I decided to try this way.
March 19th 20 at 09:15
3 answers
March 19th 20 at 09:17
Solution
Include the output of any errors that look does something on request
<?php
ini_set('error_reporting', E_ALL); // turn the output all errors
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
require_once('db.php');

if(isset($_POST['delivery_date']))
{
 $get_date = $_POST['delivery_date'];
 var_dump($get_date); //look does something on request
 $SQL = "SELECT * FROM $dbtable WHERE delivery_date='$get_date' AND delivery='1' ORDER BY id DESC";
 $result = mysqli_query($link, $SQL);
var_dump( $result); //see the result

 while ($res = mysqli_fetch_assoc($result)) {
 printf ("%s\n", $res["delivery_date"]);
}
}
?>
Fatal error: Uncaught Error: Function name must be a string in C:\OpenServer\OSPanel\domains\admin\date.php:9 Stack trace: #0 {main} thrown in C:\OpenServer\OSPanel\domains\admin\date.php on line 9
Line 9 - $date = $_POST(['delivery_date']);
What's wrong with her? - Arnold commented on March 19th 20 at 09:20
@Arnold, rename the function $get_form_date well, or otherwise... - tatum.Cronin commented on March 19th 20 at 09:23
@tatum.Cronindid
if(isset($_POST['delivery_date']))
{
 $form_date = $_POST(['delivery_date']);
 var_dump($form_date); //look does something on request
 $SQL = "SELECT * FROM $dbtable WHERE delivery_date='$form_date' AND delivery='1' ORDER BY id DESC";
 $result = mysqli_query($link, $SQL);

Still the same error - Arnold commented on March 19th 20 at 09:26
@Arnold, $form_date = $_POST['delivery_date']; - tatum.Cronin commented on March 19th 20 at 09:29
@tatum.Cronin, that's what got output:
string(10) "2019-01-01" 2019-01-01 - Arnold commented on March 19th 20 at 09:32
@Arnold, Right, received a delivery date from the form which was specified, it displays the line var_dump($form_date); - tatum.Cronin commented on March 19th 20 at 09:35
Clear. And then what to do? How do I only display records from the database for this received date? :) - Arnold commented on March 19th 20 at 09:38
@Arnold, I look like a teacher?))
See what's next You have code that displays Your query in the database any data, if not then think why.
var_dump( $result); - tatum.Cronin commented on March 19th 20 at 09:41
@tatum.Cronin, get this:
bject(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(23) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } 2019-01-01
Apparently the query is compiled correctly? - Arnold commented on March 19th 20 at 09:44
March 19th 20 at 09:19
$get_date = $_POST(['delivery_date']);
Should be:
$get_date = $_POST['delivery_date'];
$_POST is an array, not a function.
March 19th 20 at 09:21
Well, you really don't see what you write? Well, not really hard to do it in the normal editor, just do not do it.

$_POST['delivery_date'] in line 9 is called like a function and is an array. Why the test above you are doing fine, and in line 9 it was necessary to invent a Bicycle and to call as a function.
Have corrected the problem of my question is still not in it.
If you do check the result, we get this:
object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(23) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } 2019-01-01 - Arnold commented on March 19th 20 at 09:24

Find more questions by tags MySQLPHP