I am using php query to retrieve information from a mysql database with mysql_fetch_array and use the returned results to query another database? Im pretty novice. Is this possible?
$search =
"SELECT `a`,`b`
FROM 'DB'
WHERE `x` LIKE '$var'
LIMIT 0 , 30";
$result = mysql_query($search, $connection);
if($result){
while ($row = mysql_fetch_array($result)){
echo $row["a"]." ".$row["b"]."<br />";
}
} else {
echo "<p> Subject search failed. <p>";
echo "<p>" . mysql_error() . "</p>";
}
<!-- SECOND QUERY -->
$search2 =
"SELECT `a`,`b`
FROM `DB`
WHERE `x` = **$row['a']** *trying to grab the result from the first query and use as search query in second?*
LIMIT 0 , 100";
$result2 = mysql_query($search2, $connection);
if($result2){
while ($row2 = mysql_fetch_array($result2)){
echo $row2["a"]." ".$row2["b"]."<br />";
}
} else {
echo "<p> Subject search failed. <p>";
echo "<p>" . mysql_error() . "</p>";
}
Could someone point me in the right direction?