$sql="SELECT * FROM oc_category where parent_id = '253' "; // grab the category id from the parent id
$result=mysqli_query($con,$sql);
$Pid=mysqli_fetch_assoc($result);
$sql="SELECT * FROM oc_category_description where category_id = '$Pid[category_id]' "; // grab the category name from the category id
$result=mysqli_query($con,$sql);
$Cid=mysqli_fetch_assoc($result);
{
// show the results
echo '<a target="_top" href="index.php?route=product/products&product_id=' .
$Cid['category_id'] . '"><span class="cat">' . substr($Cid['category_id'], 0,
50),('') . '</span></a><br>' . '' . "\n";
}
Asked
Active
Viewed 31 times
-2

NotThatGuy
- 11
- 1
-
1Without your schema it is impossible to tell the reason. So plz share the schema. – Ankit Bajpai Jan 13 '15 at 13:55
-
I am so sorry, bu what do you mean by schema? – NotThatGuy Jan 13 '15 at 16:19
1 Answers
0
I think you are better off doing a join - so that you only have one query. Your new query would be:
SELECT desc.*
FROM oc_category cat, oc_category_description desc
WHERE cat.parent_id = '253'
and cat.category_id = desc.category_id

chiefmanc
- 38
- 5