I want to list all the categories in a page. Each posts have a column with their corresponding category id (numerical). Now how do i list all the categories in a page?
unfortunately this code displays the category everytime it exists :facepalm:
PHP:
$db = mysql_connect(HOST,UNAME,PASS);
mysql_select_db(DBNAME);
$query = mysql_query("select * from POSTS");
while($row = mysql_fetch_object($query)){
switch($row->category){
case 1: echo 'Category A';break;
case 2: echo 'Category B';break;
case 3: echo 'Category C';break;
case 4: echo 'Category D';break;
case5: echo 'Category E';break;
default: echo 'Uncategorized';
}
unfortunately this code displays the category everytime it exists :facepalm: