Hello, i have a problem. I want to do two things
First, explode an array to retrieve the ids from a row on the table
e.g. 1,5,23 and then use a variable to call a Mysql statement.
Here is my code
public function Show($times)
{
$q=mysqli_query($this->db,"SELECT to_uid_fk FROM table WHERE status='1' ") or die(mysqli_error($this->db));
$row1=mysqli_fetch_array($q,MYSQLI_ASSOC);
if(strlen($row1['to_uid_fk'])>1)
{
$s = explode(",", $row1['to_uid_fk']);
foreach($s as $a)
{
$query=mysqli_query($this->db,"SELECT row1,row2,to_uid_fk,times FROM table WHERE to_uid_fk='$a' ORDER BY row1 DESC ")or die(mysqli_error($this->db));
while($row=mysqli_fetch_array($query,MYSQLI_ASSOC))
{
$times=$row['times'];
$data[]=$row;
}
return $data;
}
}
}
and then i want to call this function on another file to run a php script as much times as the row times is set. The row times on the table stores an integer number of course.
here is the code
$Show=$db->Show($times); //dont mind that i know its wrong
if($Show)
{
$count=0;
for( $i=0; $i<$times; $i++ )
{
foreach($Show as $data)
{
echo $data['row1'].$data['row2'].$data['row3'];
}
$count += $times;
}
?>