I know just the title hurt. I feel like i'm in inception. I am using 2 different databases. I am trying to use a while loop to pick up 4 values from the first database using a while loop. Then I want to use a while loop inside a foreach loop to find the name and the related law for each of those 4 values. I have tried different codes this one gets me the closest but only returns the first value not the other three.
$link1 = mysql_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_dblogin);
if(!$link1 || !mysql_select_db ($mysql_dblogin)) {
die ($conn_error_message);
}
$link2 = mysql_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db, TRUE);
if(!$link2 || !mysql_select_db ($mysql_db)) {
die ($conn_error_message);
}
$sql="SELECT loi FROM $username";
$result = mysql_query("$sql", $link1);
$data = array();
if($result){
WHILE($row=mysql_fetch_assoc($result)){
$data[]=$row;
foreach($data as $vote){
$loi = $vote['loi'];
$sql="SELECT objet, colo FROM scruinfo WHERE colo = '$loi' ";
$result=mysql_query("$sql", $link2);
if($result){
WHILE($row=mysql_fetch_assoc($result)){
$loi = $row["colo"];
$name = $row["objet"];
echo "<table><td href='votes.php?loi=".$loi."'>".$name."</td></table><br>";
}
}
}
}
}else{
echo mysql_error();
}
?>