0

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

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by MagicMedia
0

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.

0

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?

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.