http://www.dynamicdrive.com/dynamicindex1/slashdot.htm this is link of menu my site consists of caterogies which contain subcategories, i want to make categories appear in the dark area and it in the sub categories appear inside the sub menu.
From what I gather you want a tree stucture, so when you click a category it expands to give subcategories? If this is correct, the best way to do this is with ajax so the page doesnt have to completely reload. Send the category name to a javascript function, the function will then load a php script which will handle which subcategories to show (possibly from a database) and what each one of them links to. This will all be done in place of a paticular element, so each category may have a div element around them, the ajax function will then replace the div element with the appropriate category and also the new categories. I have an example of ajax in place at projectword.co.uk. Search for a word, go to define it, then add it to the basket. The div underneath "Add to basket" is replaced with the appropriate information. I hope this is a help. If this is what you need I have code I have written which could be of a use to you Thanks ProjectWORD
i think ur description is right,but ur code is so different if u have an ajax code or any code that do that plz help us i have database contain categories and each category contain some subcategories ,i want them in a menu containing these items and sub items waiting
Ok, well wrap a div around each category, give them an id of the corresponding category. In the link, make an onclick event to a function in a .js file. (Ensure you link to your .js file in your <head></head> section) The javascript that will work for this is:- var xmlHttp function showCategory(category) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="category_change.php" url=url+"?category="+category url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById(category).innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } There are three key elements of this. 1) The link to a php script that will handle all database manipulation and displaying the relevant information 2) The name of the div that the php script will replace 3) The arguement that is passed to the script, use this to know what category the user has clicked on and therefore select the relevant subcategories. I hope this is a help to you. Post a reply if you need any more help. (PM me as you did to remind me) Regards projectWORD http://www.projectword.co.uk
i am sorry i am a beginner ,so i cant understand this if u can do me a favour and help me in the coding my code to read categories is i want to show the subcategories of each category
<? $conn=mysql_connect("localhost","root","root"); mysql_select_db('project3'); $sql="select * from category"; $rs=mysql_query($sql); while($data=mysql_fetch_array($rs)) { $cat = $data['name']; ?> <a href="#" onclick="loadSubCat('<? print $cat; ?>')" /><? print $cat; ?></a> <? } ?> Then create a javascript file with the function loadSubCat as like the one I showed you. Ensur you have this in your header <script src="NAMEOFFILE.js"></script>