I am using php to list out categories for a particular item while making blog.But i am listing out all the categories which are present in database in the list.I created a category table in my database.my code is listed as follows:
<?php
include 'connection.php';
$list ="select name from categories";
//$list = "SELECT DISTINCT name FROM categories";
$rlist = mysql_query($list) or die(mysql_error());
while($rows = mysql_fetch_assoc($rlist))
{
$catname = $rows['name'];
echo '<li><a href="/index.php?id=' . $catname . '">' . $catname . '</a></li>';
}
?>
this is categories table
id name p_id
1 new release 3
2 videos 3
3 Trailer 3
4 Latest song 3
5 New Devices 4
6 Mobiles 4
7 PC 4
i created blog for movies,gadget,design..p_id is the respective ids of movies,gadget,design.Name is the subcategory of movies,gadget,design.movies,gadget,design comes under another table called page.Any help would be appreciated