I have a script that brings the results of a sql search as follows:
$sql = (...);
$result = $db->query($sql);
while ($obj = mysqli_fetch_object($result)) {
$ids = $obj->id_prestador.",";
}
If I make an echo $ ids after creating the $ ids, it brings for example: "710, 720, 730,".
On another page I would like to be able to get this information so I can run a script that sends these ID's to an application, how can I do it?
I tried a cookie that would be best for me, but then it only brought the 1st result ("710,").
$sql = (...);
$result = $db->query($sql);
while ($obj = mysqli_fetch_object($result)) {
$ids = $obj->id_prestador.",";
setcookie("cookieprestador",$ids)
}
I wanted to be able to grab any $ ids page such as "710, 720, 730,".
UPDATING: I have an array and I used implode and it worked, but when I do the setcookie it gives warning message: Can not modify header information already sent by output started at .....
Below is how it was:
$files = array();
while ($obj = mysqli_fetch_array($result)) {
$files[] = $obj["id_prestador"];
}
$string = implode(', ', $files);
setcookie("cookieprestador",$string);