Hi i have 2 files one is Left.php which is is getting categories of product...code is

<?php
		require('Connection.php');
		
		$query ="select distinct(P_Category) from tblProducts_info";
		
		$result = mysql_query($query);
		
		if(!$result)
		{
			die('echo invalid query:,mysql_error()');
		}
		else
		{
			if(mysql_num_rows($result)>0)
			{
		
		while($rows= mysql_fetch_array($result))
		{
			$P_Category = $rows['P_Category'];
			$cat_List="";
		
		
		   $cat_List = "<li class=\"odd\"><a href=\"services.html\"?P_Category=$P_Category>$P_Category</a></li> ";
		   }}
		}
?>

another file is main.php where i include above file....

<?php include('Breaks/Left.php'); ?>

But the problem is i m only able to see one categorie in my page.....and i want to see all categories in page...
Hope somebody will help me...

Regards....
Farhad

Recommended Answers

Hi i have 2 files one is Left.php which is is getting categories of product...code is

<?php
		require('Connection.php');
		
		$query ="select distinct(P_Category) from tblProducts_info";
		
		$result = mysql_query($query);
		
		if(!$result)
		{
			die('echo invalid query:,mysql_error()');
		}
		else
		{
			if(mysql_num_rows($result)>0)
			{
		
		while($rows= mysql_fetch_array($result))
		{
			$P_Category = $rows['P_Category'];
			$cat_List="";
		
		
		   $cat_List = "<li class=\"odd\"><a href=\"services.html\"?P_Category=$P_Category>$P_Category</a></li> …
Jump to Post

All 3 Replies

Hi i have 2 files one is Left.php which is is getting categories of product...code is

<?php
		require('Connection.php');
		
		$query ="select distinct(P_Category) from tblProducts_info";
		
		$result = mysql_query($query);
		
		if(!$result)
		{
			die('echo invalid query:,mysql_error()');
		}
		else
		{
			if(mysql_num_rows($result)>0)
			{
		
		while($rows= mysql_fetch_array($result))
		{
			$P_Category = $rows['P_Category'];
			$cat_List="";
		
		
		   $cat_List = "<li class=\"odd\"><a href=\"services.html\"?P_Category=$P_Category>$P_Category</a></li> ";
		   }}
		}
?>

another file is main.php where i include above file....

<?php include('Breaks/Left.php'); ?>

But the problem is i m only able to see one categorie in my page.....and i want to see all categories in page...
Hope somebody will help me...

Regards....
Farhad

You assign your $cat_list variable twice per loop. Just echo it out instead of giving it a new value.

PS. Your anchor syntax is wrong. The whole link goes inside the href.

You assign your $cat_list variable twice per loop. Just echo it out instead of giving it a new value.

PS. Your anchor syntax is wrong. The whole link goes inside the href.

i also use catlist once but not worked...

i didn't get anchor syntax wrong? could u define it?

Inside your loop, after you define your variable:

echo $cat_List;

As for your anchor, you're posting GET data outside the href attribute so browsers won't even know what to do with it. And you're sending it to an .html file which is client side code so it won't be processed either way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.