Good night. There is such a table
num | id 2 | 5435 3 | 785 1 | 964 How to select id by sorting num and output each id to different variables, for example $ id1, $ id2, $ id3 (of course, via PDO)?
The task, as written in the comments - is the lishin of all logic .. well, okay)
$a = $log->db->query("SELECT `id` FROM `logs` WHERE 1 ORDER BY `num` DESC")->fetchAll(PDO::FETCH_COLUMN); foreach ($a as $aa){ $var_name="id$aa"; $$var_name=$aa; } print_r($a); /* Array ( [0] => 9459871 [1] => 9459872 [2] => 9459873 ) */ echo $id9459871; // вернет 9459871 Source: https://ru.stackoverflow.com/questions/635841/
All Articles
$id1 $id2 $id3, in not an array? What caused this strange behavior? And if in the table there are 1000000 lines? - Alexey Shimansky