Update 2013/12/23 In other words, I have two tables within one database.
If a category exists in one table (e.g.: 43 in featured table) and also exists in another table (43 in category table) then match category ID relevant to the name and if true do something (e.g.: echo).
As far as I can tell nesting an if statement within an if statement that perform two separate MySQL queries doesn't allow me to keep the values of the parent if statement.
I need to somehow store the parent values from the MySQL value so they can be retrieved within the child if statement.
------------------------------
If the category ID in my category_description table exists in another table called sales_promotion then I want to execute another PHP statement.
After doing some research my code so far looks like this
$con = mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWORD);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
foreach ($breadcrumbs as $breadcrumb) {
$db_selected = mysql_select_db(DB_USERNAME,$con);
$sql = "SELECT * FROM `sales_promotion` LIMIT 0, 30";
$result = mysql_query($sql,$con);
$sql_categories = "SELECT * FROM `category_description` LIMIT 0, 30";
$result_categories = mysql_query($sql_categories,$con);
$test = mysql_fetch_array($result);
while($row = mysql_fetch_array($result_categories))
{
if (strpos($row['name'],$breadcrumb['text']) !== false) {
echo('<p>Category '.$row['name'].' contains '.$row['category_id'].'</p>');
$category_id = $row['category_id'];
while($row = mysql_fetch_array($result))
{
if (strpos($row['options'],$row['category_id']) !== false) {
echo('<p>Category '.$row['name'].' contains '.$category_id.'</p>');
}
}
}
}
}
mysql_close($con);
Could someone please explain how I can achieve this?