I have this mysql query that i want to loop till there is no more result found in the table,
$sql_query="select id from rev_r_clients WHERE parent_client_id='$id'";
$res = mysql_query($sql_query);
$ids=array();
while($row = mysql_fetch_object($res)){
$ids[]=$row->id;
}
$ids=array_filter($ids);
foreach($ids as $id){
echo $id;
}
and what i want is loop the same query again and again like this:
$sql_query="select id from rev_r_clients WHERE parent_client_id='$id'";
$res = mysql_query($sql_query);
$ids=array();
while($row = mysql_fetch_object($res)){
$ids[]=$row->id;
}
$ids=array_filter($ids);
foreach($ids as $id){
echo $id;
$sql_query="select id from rev_r_clients WHERE parent_client_id='$id'";
$res = mysql_query($sql_query);
$ids=array();
while($row = mysql_fetch_object($res)){
$ids[]=$row->id;
}
$ids=array_filter($ids);
foreach($ids as $id){
echo $id;
}
}
this last code will loop the query twice but the problem i have is that i want to loop it till there is no more result found
$sql_query="select id from rev_r_clients WHERE parent_client_id='$id'";
$res = mysql_query($sql_query);
$ids=array();
while($row = mysql_fetch_object($res)){
$ids[]=$row->id;
}
$ids=array_filter($ids);
foreach($ids as $id){
echo $id;
<--! REPEAT SAME CODE IN HERE AGAIN AND AGAIN AND AGAIN --> }
looping 3 times:
$sql_query="select id from rev_r_clients WHERE parent_client_id='$id'";
$res = mysql_query($sql_query);
$ids=array();
while($row = mysql_fetch_object($res)){
$ids[]=$row->id;
}
$ids=array_filter($ids);
foreach($ids as $id){
echo $id;
$sql_query="select id from rev_r_clients WHERE parent_client_id='$id'";
$res = mysql_query($sql_query);
$ids=array();
while($row = mysql_fetch_object($res)){
$ids[]=$row->id;
}
$ids=array_filter($ids);
foreach($ids as $id){
echo $id;
$sql_query="select id from rev_r_clients WHERE parent_client_id='$id'";
$res = mysql_query($sql_query);
$ids=array();
while($row = mysql_fetch_object($res)){
$ids[]=$row->id;
}
$ids=array_filter($ids);
foreach($ids as $id){
echo $id;
}
}
}
so how do i repeat the code infinite times till there is no result in the database