Hello, dear!
I had a problem, the fact is that I am making a small application, and at this stage I have to set the output of user data by their id. For this, I want to use the users.get method, and pass all user data in one request. But the problem is that you need to somehow pack all the data from the array into a string and for that there is an implode function, but the fact is that when using mysql_fetch_assoc, I only get one cell of all the columns, not all at once.
How can this problem be solved? I admit that overwriting an array into another. But maybe there is a function? PS About mysqli_fetch_all read, but it did not work with it + it is turned off on many hosts. The code itself:
<?php require_once('db.php'); $sql_connection = dbConnect(); $_REQUEST['viewer_id'] = 2; function getUsers($user_id, $sql_connection){ $sql_query = "SELECT * FROM `catch_up` WHERE `owner_id` LIKE ".$user_id." "; $sql_response = mysql_query($sql_query); return $sql_response; } function showUsers($sql_response,$sql_connection){ while ($row = mysql_fetch_assoc($sql_response)){ // Тут должен быть вывод данных } } $sql_response = getUsers($_REQUEST['viewer_id'],$sql_connection); showUsers($sql_response,$sql_connection); ?> UPD:
While I tried:
$data = array(); while($row = mysql_fetch_assoc($sql_response)) { $data[] = $row; return $data; } + then var_dump array
But all the same one output, instead of two: (
UPD 2: I am a rakan, I put return into a loop. I'll fix it now. UPD 3:
We have already decided at least somehow the first problem, now the problems with Implode.
When implode, for some reason, it does not glue everything into a string, but returns with var_dump: string (11) "Array, Array" The code itself (screenshot): pp.vk.me/c630925/v630925489/448b7/J6bHjj_eNmY.jpg What is wrong? The data array itself contains the following form: array (2) {[0] => array (1) {["v_id"] => string (1) "1"} 1 => array (1) {["v_id" ] => string (1) "2"}}
while ($rows[] = mysql_fetch_assoc($sql_response)); print_r($rows);while ($rows[] = mysql_fetch_assoc($sql_response)); print_r($rows);Well, note that the methods are obsolete. - Bookin