Hi,
While I’m trying to program my own script i faced some problems :
1 - problem with sub_categories
the data base looks like :
"`id`,`name`,`url`,`sub_cat`"
and the sub_cat column should have the id of the sub categories in this way :
1,2,5
in the php file :
$url = $_GET['url'];
$query = mysql_query("SELECT `id`,`name`,`url`,`sub_cat` FROM `cats` WHERE `url` = '$url' LIMIT 1");
list($id,$name,$url,$sub_cat) = mysql_fetch_array($query);
if($sub_cat != "none") {
$sql = mysql_query("SELECT `url` FROM `cats` WHERE `id` IN ($sub_cat)");
if(mysql_num_rows($sql) > 0) {
while(list($urls) = mysql_fetch_array($sql)) {
$OR = "OR `cat` = '$urls' ";
}
}
}
and i should start a new query to get the articles which had the same $urls :
$query = mysql_query("SELECT `id`,`name`,`text`,`cat` FROM `articles` WHERE `cat` = '$url' $OR ORDER BY `id` DESC LIMIT 20");
while(list($aid,$aname,$atext,$acat) = mysql_fetch_array($query)) {
echo "<h1>$aname</h1>\
<br />\
<div class='text'>$atext</div>\
<br /><br />\
<h3>$acat</h3>";
}
but when i open main category it doesn’t show all topics in the main category and in the sub ones
i tried to make OR query like this one :
$OR = "OR `cat` IN ('$urls') ";
but it didn’t work either so how can i show all articles in the main and the sub cats ??
And Thank You In Advance