How to handle selection and conclusion date?

Good afternoon.
I need to get all posts from database for a specified date.
Here is the date picker:
<form method="post" name="date" action="date.php" >
 <input class="form-control" type="date" name="delivery_date" value="<?=htmlspecialchars(date('Y-m-d', strtotime($users['delivery_date'])), ENT_QUOTES)?>" id="example-date-input"> <button type="button" class="btn btn-primary btn-xs mb-3">Find</button>
 </form>


But what I've done in php:
<?php

require_once('db.php');

if(isset($_POST['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);

if ($result) {
header('Location:print.php');
}
else {
 printf("Error: %s\n", mysqli_error($link));
}
}
?>

Most likely I incorrectly made a request or gave an incorrect date. Please help me to understand how exactly do I correctly pass the date and get the data for it from the table and also how can I then display the page.
March 19th 20 at 09:11
2 answers
March 19th 20 at 09:13
Solution
working version:
<?php
require_once('db.php');
?>
<form method="post" action="">
<input type="date" name="delivery_date"> 
<input type="submit" value="Find">
</form>
<?
if(isset($_POST['delivery_date'])) 
{
 $date = $_POST['delivery_date'];
 $SQL = "SELECT * FROM $dbtable WHERE delivery_date = '$date' AND delivery = 1";
 $result = mysqli_query($link, $SQL);

 while ($res = mysqli_fetch_assoc($result))
{
 echo $res["user"]." (".$res["delivery_date"].")<br>";
}
} 
?>
March 19th 20 at 09:15
To a string $date = date('Y-m-d', ['delivery_date']; You should not substitute the string as You are doing now, and a timestamp.
As you do You will fail.
But it should work:
$date = date('Y-m-d', strtotime('delivery_date'));
That is, if the date in $delivery_date You about in the form of "4-03-2019" or similar.
have you ever tried to do $date = date('Y-m-d', strtotime(['delivery_date']));? - Rusty_Beck commented on March 19th 20 at 09:18
@Rusty_Beck, Yes, and all works successfully. Another question that the author of the question gets into that variable? - Daija commented on March 19th 20 at 09:21
again at this line more closely :) - Rusty_Beck commented on March 19th 20 at 09:24
@Rusty_Beck, it is not my task to seek out errors. - Daija commented on March 19th 20 at 09:27
@Daija
The date was originally in another table written in this format.
<input class="form-control" type="date" name="delivery_date" value="<?=htmlspecialchars(date('Y-m-d', strtotime($users['delivery_date'])), ENT_QUOTES)?>" id="example-date-input">
- myrna.Kemme commented on March 19th 20 at 09:30
@myrna.Kemme, OK, and at $del_date have. - eulalia.Lars commented on March 19th 20 at 09:33
@eulalia.Lars, Yes, the table is filled. - myrna.Kemme commented on March 19th 20 at 09:36
@myrna.Kemme, need to look where they are interrupted... take a withdrawal of $date if it's correct, then you can conclude $del_date, apparently to display somewhere lost the thread... may not come in the date and then the table will not fetch the returned array can be empty... that's why it stuck to the date, because $_POST['date'] to verify the conditions just do not exist, there is $_POST['delivery_date'], I'm in .js do not rummage and I don't know you they pass this variable to check for existence... if not, then everything in the curly brackets - will not run... need to look where the thread is lost - eulalia.Lars commented on March 19th 20 at 09:39
@myrna.Kemme, the form in which You have stored the date in the table and in what form comes in the POST? - Daija commented on March 19th 20 at 09:42
@myrna.Kemmein the $_POST array keys are stored with field names and not the form, so I stuck in comments to the code above... because I do not understand where it came from $_POST['date'] in the line if(isset($_POST['date'])) - eulalia.Lars commented on March 19th 20 at 09:45
@Daija, the format is varchar. In practice looks like this: 2008-09-14 . - myrna.Kemme commented on March 19th 20 at 09:48
@myrna.Kemmeis in the table and in the POST? - Daija commented on March 19th 20 at 09:51
@eulalia.Lars, the name of the field is also a date, although I know what not to do... - myrna.Kemme commented on March 19th 20 at 09:54
@Daijamust be in the same form - myrna.Kemme commented on March 19th 20 at 09:57
@myrna.Kemme, формыdate name and the field name you delivery_date, do not confuse, in the $_POST array is written the name of the field and not the form name - eulalia.Lars commented on March 19th 20 at 10:00
@myrna.Kemme,
input class="form-control" type="date" name="delivery_date"...

field name is passed as the key and not the name of the form, here where you enter the date field name delivery_date - eulalia.Lars commented on March 19th 20 at 10:03
@myrna.Kemme, should, and really in what? - Daija commented on March 19th 20 at 10:06
@eulalia.LarsCorrected code - myrna.Kemme commented on March 19th 20 at 10:09
@Daija, I may not rummage, but how do I know what really happens?) - myrna.Kemme commented on March 19th 20 at 10:12
@myrna.Kemme, print_r($_POST); - Daija commented on March 19th 20 at 10:15
@Daija, Array ( [date] => 2008-09-14 ) - myrna.Kemme commented on March 19th 20 at 10:18
@Daija, I would start with $del_date ) - eulalia.Lars commented on March 19th 20 at 10:21
@myrna.Kemme, as well with the $date and $del_date make - eulalia.Lars commented on March 19th 20 at 10:24
@eulalia.Lars, explain to the needy that how and where, please. - myrna.Kemme commented on March 19th 20 at 10:27
@myrna.Kemme,
print_r($date);
And then
print_r($del_date); - eulalia.Lars commented on March 19th 20 at 10:30
@eulalia.Lars, where exactly and how I need it to paste in the code? - myrna.Kemme commented on March 19th 20 at 10:33
@myrna.Kemme, insert before return) - eulalia.Lars commented on March 19th 20 at 10:36
@eulalia.Lars, I'm tinkering, I came to a bit different approach)
Take a look, plz, the code in question, I decided to do without the functions and output cycle. - myrna.Kemme commented on March 19th 20 at 10:39
@myrna.Kemme, cycle print.php?) - eulalia.Lars commented on March 19th 20 at 10:42
@eulalia.Lars, Yes - myrna.Kemme commented on March 19th 20 at 10:45
@myrna.Kemme, works? Or not? - eulalia.Lars commented on March 19th 20 at 10:48
@eulalia.Lars, I don't know, I haven't figured out how to output this cycle :)
I previously on another page and output the same data but without the conditions of a choice of date.
Looked like this:
<?php
 $post = get_users();
?>
 <?php foreach ($post as $users): ?>

<td><textarea class="form-control" type="text" name="phone" value="" id="example-text-input"><?=htmlspecialchars($users['phone'], ENT_QUOTES)?></textarea></td>
<?php endforeach; ?>

And here is how the php file looked like, from which it was taken:
function get_users() {
 global $link;
 $sql = "SELECT * FROM Users WHERE reject = '0' AND delivery = '0' ORDER BY id DESC";
 $result = mysqli_query($link, $sql);
 $users = mysqli_fetch_all($result, MYSQLI_ASSOC);
 return $users;
}

And in fact it turns out it displayed all in the page load time in reverse order.
I decided to do something similar and ruined, because I do not understand how can I correctly output the table after selecting a date in the form and pressing the button :( - myrna.Kemme commented on March 19th 20 at 10:51
@myrna.Kemme, actually all fits together again in the wrong name keys) do you have the code on .js bound to the form? - eulalia.Lars commented on March 19th 20 at 10:54
@eulalia.Lars, no, no code on js for form no - myrna.Kemme commented on March 19th 20 at 10:57
@myrna.Kemme, I worked with php 5 years ago) and if your code is gash at the time, we get something like that)
<?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"]);
}
}
?>

from what you have provided here) - eulalia.Lars commented on March 19th 20 at 11:00
@eulalia.Lars, well, I washed down this code in the file)
And then what do I do? This is my biggest concern, I place the data derived from it on the page) - myrna.Kemme commented on March 19th 20 at 11:03
@myrna.Kemme, and
header('Location:print.php');
this header will not work...
header - eulalia.Lars commented on March 19th 20 at 11:06
@myrna.Kemme,
printf ("%s\n", $res["delivery_date"]);
this is the data output to the page my column all the dates which were returned by the database query. - eulalia.Lars commented on March 19th 20 at 11:09
@eulalia.Lars, then either I have something wrong, or it doesn't work :) I Have a blank page returned - myrna.Kemme commented on March 19th 20 at 11:12
<?php
require_once('db.php');
?>
<form method="post" action="">
<input type="date" name="delivery_date" value="<?=htmlspecialchars(date('Y-m-d', strtotime($users['delivery_date'])), ENT_QUOTES)?>"> 
<input type="submit" value="Find">
</form>
<?
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"]);
}
}
?>

here is the code that can be stored in a separate file and check the blind of your pieces... in the form of removing unneeded values... check the path of external file - eulalia.Lars commented on March 19th 20 at 11:15
@eulalia.Lars, Fatal error: Uncaught Error: Function name must be a string in \admin\pisos.php:11 Stack trace: #0 {main} thrown in \admin\pisos.php on line 11 - myrna.Kemme commented on March 19th 20 at 11:18
@myrna.Kemme, only I don't know where is $users['delivery_date'] - eulalia.Lars commented on March 19th 20 at 11:21
@eulalia.Lars, if you're talking about value in the input date, it's just a vestige, I threw it away :) - myrna.Kemme commented on March 19th 20 at 11:24
@myrna.Kemme, no error in this code... there are 11 line variable assignment - eulalia.Lars commented on March 19th 20 at 11:27
@eulalia.Lars, I'm too stupid to understand what is wrong with this variable :(
I spent the entire night trying to solve a seemingly simple task - myrna.Kemme commented on March 19th 20 at 11:30
@myrna.Kemme,
<?php
require_once('db.php'); //connection file to your dB
?>
//here is the working form 100%
<form method="post" action="">
<input type="date" name="delivery_date"> 
<input type="submit" value="Find">
</form>
<?
if(isset($_POST['delivery_date'])) //check whether exists delivery_date variable which should come from the form
{
 $date = $_POST(['delivery_date']); //assign the value of the variable from the form
 $SQL = "SELECT * FROM $dbtable WHERE delivery_date='$date' AND delivery='1' ORDER BY id DESC"; //your query text to the database
 $result = mysqli_query($link, $SQL); //do request, apparently the variable link is obtained from the file db.php

 while ($res = mysqli_fetch_assoc($result)) { // the result from the base convertible to the associations array and iterate in a loop
 printf ("%s\n", $res["delivery_date"]); //print the date of each returned string array
 } // close loop
} //close the condition
- eulalia.Lars commented on March 19th 20 at 11:33
@eulalia.Lars, I understand that the variable does not exist, maybe this error again - myrna.Kemme commented on March 19th 20 at 11:36
@myrna.Kemme, can I have brake... sleep easy... try it yourself to collect all or change your other work... - eulalia.Lars commented on March 19th 20 at 11:39
@eulalia.Lars, look slightly changed the code.
<?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']))
{
 $form_date = $_POST['delivery_date'];

 $SQL = "SELECT * FROM $dbtable WHERE delivery_date='$form_date' AND delivery='1' ORDER BY id DESC";
 $result = mysqli_query($link, $SQL);
 var_dump($result); //look does something on request

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

The result is
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
Apparently I have a request, maybe rewrite? - myrna.Kemme commented on March 19th 20 at 11:42
@myrna.Kemme, let's simplify)
$dbtable instead of the variable in the query string, substitute the table name - eulalia.Lars commented on March 19th 20 at 11:45
@eulalia.Lars, already tried :(
All the same - myrna.Kemme commented on March 19th 20 at 11:48
@eulalia.Lars, I tried a little bit different to make a request, I got this.
$SQL = "SELECT phone FROM Users WHERE delivery_date='$form_date' AND delivery='1'";
it is the request itself, and that's what we get.
object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"]=> NULL ["num_rows"]=> int(2) ["type"]=> int(0) }
Notice: Undefined index: delivery_date in C:\OpenServer\OSPanel\domains\admin\date.php on line 16

Notice: Undefined index: delivery_date in C:\OpenServer\OSPanel\domains\admin\date.php on line 16
Tried to change printf ("%s\n", $res["delivery_date"]);
on
printf ("%s\n", $res["phone"]);
And got the numbers...
I think I began to understand, but this is not accurate. - myrna.Kemme commented on March 19th 20 at 11:51
@myrna.Kemme, in short, the necessary file db.php can the database name, host and pass to gash asterisks - eulalia.Lars commented on March 19th 20 at 11:54
@myrna.Kemme, doom you to the wrong table appeal - eulalia.Lars commented on March 19th 20 at 11:57
Kaku in the table stored date of delivery? - eulalia.Lars commented on March 19th 20 at 12:00
@eulalia.Lars, here db.php it just a table, but it is one in the database)
<?php

//Connection settings to the database
$host = "localhost"; //host name
$database = "test1"; //database name
$user = "root"; //user
$password = ""; //password
$dbtable = "Users"; //table

$link = mysqli_connect($host, $user, $password, $database)
or die("Error" . mysqli_error($link));

?>
- myrna.Kemme commented on March 19th 20 at 12:03
@eulalia.Lars, all in the Users table, it is one in the database.
5c9f13f509d1a630567525.png
Here its structure.
5c9f1416df9e4259519141.png
It looks like the delivery date, they date, they are varchar - myrna.Kemme commented on March 19th 20 at 12:06
@myrna.Kemme, well, there are rules, the query finds no records here ...
SELECT * FROM $dbtable WHERE delivery_date='$form_date' AND delivery='1' ORDER BY id DESC
It literally sounds like a "to SELECT all the fields in the TABLE $dbtable(actual Users) in WHICH the field delivery_date is equal to the variable $from_date And delivery field equal to 1 and then about sorting in reverse order - eulalia.Lars commented on March 19th 20 at 12:09
@eulalia.Lars, in my version, I have removed the sort, it is not needed. What the query does, I also understand.
I'm stupid only question is how do I display all :( - myrna.Kemme commented on March 19th 20 at 12:12
Option 2)
-in the Users table there are no fields or delivery_date delivery, or both...
for the selected date there are no records that meet the date and have 1 in the box delivery
Therefore, the query does not find any results and returns an empty object - eulalia.Lars commented on March 19th 20 at 12:15
@myrna.Kemme, so, another option, that if the date in a varchar you need to convert $_POST in a string of the appropriate form... for sravnenie character should be - eulalia.Lars commented on March 19th 20 at 12:18
@eulalia.Lars, I was there earlier screen tables attached - it has these fields.
selected date is the record, if I do so:
$SQL = "SELECT comment FROM Users WHERE delivery_date='$form_date' AND delivery='1'";
 $result = mysqli_query($link, $SQL);


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

Get a page with "this comment is коммент2" I have just the two records with delivery=1 and selected date, i.e., their comment fields unloaded. - myrna.Kemme commented on March 19th 20 at 12:21
@eulalia.Lars, i.e. the idea of it kind of like started to work, but not completely :)
I need to understand how to properly display the data of ALL fields for this date and also how it's displayed on the page where I choose the date, or at least a copy of it :) - myrna.Kemme commented on March 19th 20 at 12:24
@myrna.Kemme, make after the line

$form_date = $_POST['delivery_date'];
printf($from_date); - eulalia.Lars commented on March 19th 20 at 12:27
The problem 99% is that something that comes with forms does not match the delivery_date field in the table - eulalia.Lars commented on March 19th 20 at 12:30
@eulalia.Lars, here's what happened:
2019-01-01это comment is коммент2 - myrna.Kemme commented on March 19th 20 at 12:33
now the computer will run check it out - eulalia.Lars commented on March 19th 20 at 12:36
@eulalia.Lars, look, maybe I can explain with an example what has been done previously.
I have a page with shipping, here it is, it indicates a data table in which delivery=1:
5c9f2d59037b0457943727.png
The structure of the page looks like this: (a lot of code, remove extra div-s)

<?php
 require_once 'functions.php';
?>

<?php
 $post = get_delivery_users();
?>
 <?php foreach ($post as $users): ?>
 <div class="col-lg-12 mt-5">
 <div class="card">
 <div class="card-body">
 <h4 class="header-title">application form number<?=$users['id']?> (<?=$users['order_date']?> <?=$users['order_time']?>)</h4>
<form>
 <input type="hidden" name="form_id" value="<?=$users['id']?>">
 <table class="table text-center">
 <thead class="text-uppercase bg-success">
 <tr class="text-white">
 <th scope="col">Room</th>
 <th scope="col">name</th>
 <th scope="col">delivery</th>
 <th scope="col">delivery date</th>
 <th scope="col">delivery Time</th>
 <th scope="col">Amount</th>
 <th scope="col"> </th>

</tr>
</thead>
<tbody>
the <tr>

 <td><textarea class="form-control" type="text" name="phone" value="" id="example-text-input"><?=htmlspecialchars($users['phone'], ENT_QUOTES)?></textarea></td>
 <td><textarea class="form-control" type="text" name="name" value="" id="example-text-input"><?=htmlspecialchars($users['surname'], ENT_QUOTES)?> <?=htmlspecialchars($users['name'], ENT_QUOTES)?> <?=htmlspecialchars($users['second_name'], ENT_QUOTES)?></textarea></td>
 <td><div class="form-group">
 <select name="delivery_adress" class="form-control">
 <? foreach(get_delivery_addresses() as $delivery_address): ?>
 <option <?if ($delivery_address == $users['delivery_adress']) echo 'selected'?>><?=htmlspecialchars($delivery_address, ENT_QUOTES)?></option>
 <? endforeach;?>
</select>
</div></td>
 <td><div class="form-group">
 <input class="form-control" type="date" name="delivery_date" value="<?=htmlspecialchars(date('Y-m-d', strtotime($users['delivery_date'])), ENT_QUOTES)?>" id="example-date-input">
</div></td>
 <td><div class="form-group">
 <textarea class="form-control" type="text" name="delivery_time" value="" id="example-text-input"><?=htmlspecialchars($users['delivery_time'], ENT_QUOTES)?></textarea>
</div></td>
 <td><textarea class="form-control" type="text" name="manager_comment" value="" id="example-text-input"><?=htmlspecialchars($users['manager_comment'], ENT_QUOTES)?></textarea></td>
 <td><button type="submit" formmethod="post" name="save" formaction="save.php" class="btn btn-rounded btn-warning mb-3">Save</button></td>
</tr>
</tbody>
</table>
</form>
 <!-- primary table end -->
 <?php endforeach; ?>


Ie it turns when the page loads I put on her table, which textare recorded data from the database, which you can change by clicking the save button.
Here is functions.php to which it refers.
get_delivery_users function() {
 global $link;
 $sql = "SELECT * FROM Users WHERE delivery = '1' ORDER BY id DESC LIMIT 25";
 $result = mysqli_query($link, $sql);
 $users = mysqli_fetch_all($result, MYSQLI_ASSOC);
 return $users;
}


And now my challenge is to do something similar, but only with the date picker...
And I though kill I can not understand how can I do it correctly :( I Understand, that we need an array of data to pass into the loop and print the values... - myrna.Kemme commented on March 19th 20 at 12:39
@myrna.Kemme, in short, the problem in the date format... if the insert query itself, the date - everything exactly, but if the date assigned to the variable and substitute the variable in the query - all does not work....
$form_date = $_POST['delivery_date']; - here, string the type string, but it doesn't work in the query... but if its contents to insert into the query - it works, just do not understand how so.... - eulalia.Lars commented on March 19th 20 at 12:42
There may be some gaps or something, and when you compare a variable with a column date of delivery - it finds nothing... - eulalia.Lars commented on March 19th 20 at 12:45
Out string to store the date as something gemorno... better the old fashioned way to use a column type date (your choice) and obtained from the mold line to convert to the same date format and compare - eulalia.Lars commented on March 19th 20 at 12:48
@eulalia.Lars, weird but works for me. Ie, if I make not just a bare select and select the comment for example, it displays the date and all the comments for that date.
"2019-01-01это comment is коммент2" - myrna.Kemme commented on March 19th 20 at 12:51
@eulalia.Lars, look, if I change code like this:
if(isset($_POST['delivery_date']))
{
 $form_date = $_POST['delivery_date'];
printf($form_date);
 $SQL = "SELECT * FROM Users WHERE delivery_date='$form_date' AND delivery=1";
 $result = mysqli_query($link, $SQL);


 while ($res = mysqli_fetch_assoc($result)) {
 printf ("%s\n", $res["phone"]);
 printf ("%s\n", $res["name"]);
 printf ("%s\n", $res["surname"]);
 printf ("%s\n", $res["second_name"]);
 printf ("%s\n", $res["comment"]);

}
}

Then the output is a string:
2019-01-01это number1 is the name 1 it is коммен1т index2 is the name 2 is коммент2

Ie it turns out that after all I correctly pass and receive the date :)
It remains to understand how can I display these values on the page... - myrna.Kemme commented on March 19th 20 at 12:54
@eulalia.Lars, I Wanted to thank you for what you helped me :)
I did it! :)
I just put this php code directly into the page and it worked :)
Can put in the answers, his solution that I pointed it as the right decision? - myrna.Kemme commented on March 19th 20 at 12:57
@eulalia.Lars, I just have to figure out how to get it all at least a column :)
5c9f66722a4e3337514671.png - myrna.Kemme commented on March 19th 20 at 13:00
@myrna.Kemme, I also switched and it worked)) now make a working version) - eulalia.Lars commented on March 19th 20 at 13:03
@eulalia.Lars, I was there a separate issue already created for the withdrawal :) - myrna.Kemme commented on March 19th 20 at 13:06
@myrna.Kemme, when all conclusion is not hard to do) in your case it's just html with php variables that we were still able to get)) I went and wondered why it doesn't work... need 3 months to recover your skills after a long break) it was a good warm-up the brain) - eulalia.Lars commented on March 19th 20 at 13:09
@myrna.Kemme, a bit complicated your code, added checkbox to select taken or not and the date of the post gets inserted into the form)
<?php
require_once('db.php');
$date = $_POST['delivery_date'];
$del = $_POST['del'];
?>
<form method="post" action="">
<input type="date" name="delivery_date" value= "<? echo$date; ?>">
<input type="checkbox" name="del" value=1 checked><br>
<input type="submit" value="Find">
</form>
<?
if(isset($date)) 
{
 $SQL = "SELECT * FROM $dbtable WHERE delivery_date = '$date' AND delivery = '$del' ORDER BY id DESC";
 $result = mysqli_query($link, $SQL);


 while ($res = mysqli_fetch_assoc($result))
{
 echo $res["user"]." (".$res["delivery_date"].")<br>";
}
}
?>
- eulalia.Lars commented on March 19th 20 at 13:12
@eulalia.Lars, I rebuilt everything to use the functions as I wanted done yesterday, but ran into oshibkoi and scored)
Now the code looks like this:
get_printed_users function()
{

 global $link;
 if (isset($_POST['delivery_date'])) {
 $form_date = $_POST['delivery_date'];
 $SQL = "SELECT * FROM Users WHERE delivery_date='$form_date' AND delivery=1";
 $result = mysqli_query($link, $SQL);
 $users = mysqli_fetch_all($result, MYSQLI_ASSOC);
 return $users;
 } else {

 $sql = "SELECT * FROM Users WHERE delivery = '1' ORDER BY id DESC LIMIT 25";
 $result = mysqli_query($link, $sql);
 $users = mysqli_fetch_all($result, MYSQLI_ASSOC);
 return $users;
}
}

And deduce the cycle:
<?php
 $post = get_printed_users();
?>
 <?php foreach ($post as $users): ?>
 <!-- table primary start -->
 <div class="col-lg-12 mt-5">
 <div class="col-md-6 mt-5">
 <div class="card">
 <div class="card-body">
 <h4 class="header-title">Profile number: <?=$users['id']?></h4>
 <ul class="list-group">
 <li class="list-group-item">Name: <?=htmlspecialchars($users['name'], ENT_QUOTES)?></li>
 <li class="list-group-item">last Name: <?=htmlspecialchars($users['surname'], ENT_QUOTES)?></li>
 <li class="list-group-item">middle name: <?=htmlspecialchars($users['second_name'], ENT_QUOTES)?></li>

etc.
- myrna.Kemme commented on March 19th 20 at 13:15

Find more questions by tags MySQLPHP