2015-01-13 7 views
-2
$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";  
     } 
+1

스키마가 없으면 이유를 알 수 없습니다. 그래서 PLZ는 스키마를 공유합니다. –

+0

정말 미안 해요. 스키마가 무슨 뜻이야? – NotThatGuy

답변

0

당신은 조인을하는 것이 더 좋다고 생각합니다. 새 쿼리는 다음과 같습니다.

SELECT desc.* 
FROM oc_category cat, oc_category_description desc 
WHERE cat.parent_id = '253' 
and cat.category_id = desc.category_id 
+0

정말 고마워요 !! 그것은 완벽하게 작동했습니다! – NotThatGuy