How to get multiple rows with mysql using php?

Hello, how can I retrieve multiple rows with mysql using php
I have this code
mysqli_query($link, "SELECT `name` FROM `ysers` ORDER BY `id` DESC");

how do you implement?
all ATP
June 5th 19 at 21:34
2 answers
June 5th 19 at 21:36
Solution
Yes, read it, the fact is that when you want to get an array so $row[0] , it not only passes the first array and all that is received from the database. I need to get all together and separately output to the screen - myrna_Towne commented on June 5th 19 at 21:39
here first loop collects all entries in a new array, and then show it where necessary. - kavon.Murphy commented on June 5th 19 at 21:42
if not difficult can to show an example or give a link? - myrna_Towne commented on June 5th 19 at 21:45
Schaub to give an example, you need to understand the task. now I do not understand what you want to do. - kavon.Murphy commented on June 5th 19 at 21:48
this abradee
$res = mysqli_query($link, "SELECT `name` FROM `ysers` ORDER BY `id` DESC");

need to here is for example
$res_1 = mysqli_fetch_assoc($res);
$res_2 = $res_1['answer 1']
$res_2 = $res_1['answer 2']
$res_2 = $res_1['answer 3']
$res_2 = $res_1['4']
and so on, all output via echo
I know how to implement it, just don't know how to implement it when you get the multiple lines.
When I did as it is written in php.net the derived weight result, I could not distinguish one line from another.

that's how it was for example
line 1 = 5;
line 2 = 8;
line 3 = 15;
and I did it all at once so 5815, and I can't get them separately like this
5
8
15 - myrna_Towne commented on June 5th 19 at 21:51
use the cycles and br - uriah87 commented on June 5th 19 at 21:54
,
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
 printf("failed to connect: %s\n", mysqli_connect_error());
exit();
}

$query = "SELECT `name` FROM `ysers` ORDER BY `id` DESC";

if ($result = $mysqli->query($query)) {

 /* fetching data and putting them into an array */
 while ($row = $result->fetch_assoc()) {
 echo $row['name'] . "<br>";
}

 /* free result set */
$result->close();
}

/* close connection */
$mysqli->close();
- kavon.Murphy commented on June 5th 19 at 21:57
thank you for the answer, and I can say please how to write these values in separate variable.
For example, $a = line 1, $b = line 2 - myrna_Towne commented on June 5th 19 at 22:00
, with a strong desire of course, but usually don't.
just assemble the array:
/* fetching data and putting them into an array */
 $data = [];
 while ($row = $result->fetch_assoc()) {
 $data[] = $row['name'];
 }
and then working with him. - kavon.Murphy commented on June 5th 19 at 22:03
June 5th 19 at 21:38
WHERE some_id IN (1,2,3,4)

Find more questions by tags PHPMySQL