kategori dosyaları:

CREATE TABLE `categories` (
`id` BIGINT NOT NULL AUTO_INCREMENT ,
`position` VARCHAR( 255 ) NOT NULL ,
`c_name` VARCHAR( 255 ) NOT NULL ,
`c_desc` TINYTEXT NOT NULL ,
`c_icon` VARCHAR( 255 ) NOT NULL ,
`c_group` VARCHAR( 255 ) NOT NULL default '0' ,
PRIMARY KEY ( `id` )
);

categories.class.php

<?php
class categories
{


var $HtmlTree;

var $name_prefix  = "&nbsp;&nbsp;";	// this is the prefix which will be added to the category name depending on its position usually use space.
var $table_name   = "categories";
var $itemsTable   = "items";		
var $CID_FieldName= "category_id";	 


var $fields = array(
// field		=> field name in database ( sql structure )
"id"  		=> "id",
"position" 	=> "position",
"name"		=> "c_name",
"desc"		=> "c_desc",
"icon"		=> "c_icon",
"group"		=> "c_group",
);

var $c_list  = array();  // DON'T CHANGE THIS
var $Group  = 0;		 // DON'T CHANGE THIS

function categories()
{

$this->HtmlTree = array(
"header" 		 => '<table width=300px border=0 cellpadding=2 cellspacing=2>',
"BodyUnselected" => '<tr><td>[prefix]&raquo;<a href="?id=[id]">[name]</a></td></tr>',
"BodySelected"	 => '<tr><td>[prefix]&raquo;<a href="?id=[id]"><strong>[name]</strong></a></td></tr>',
"footer"		 => '</table>',
);

}
function add_new($parent = 0 , $name , $desc , $icon )  // add new category
{
// lets get the position from the $parent value
$position  = $this->get_position($parent);

// lets insert add the new category into the database.
$sql = "INSERT into ".$this->table_name."(position,c_name,c_desc,c_icon,c_group)
		VALUES('','".$name."','".$desc."','".$icon."','".$this->Group."')";

mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

$position .= mysql_insert_id().">";

$sql = "UPDATE ".$this->table_name."
		SET position = '".$position."'
		WHERE id = '".mysql_insert_id()."'";

mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
}
function delete($id,$items=NULL) // delete this category and all categories under it [set $items=1 if you need to delete associated items too, needs the 2 variables $itemsTable,$CID_FieldName]
{
$position = $this->get_position($id);

if($items==1) // delete associated items
{
	if($this->itemsTable == "" OR $this->CID_FieldName==""){
	die("<br><storng><u>Class Error:</u></strong><br>Either items Table name Or CID field name is blank!<br><br>");
	}

$sql = "SELECT id
		FROM ".$this->table_name."
		WHERE position LIKE '".$position."%'";
$res = mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

while($category = mysql_fetch_array($res)){

$sql2 = "Delete	FROM  ".$this->itemsTable."
		WHERE ".$this->CID_FieldName." = '".$category["id"]."'";
$res2 = mysql_query($sql2) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
}
}

$sql = "DELETE FROM ".$this->table_name."
		WHERE position
		LIKE '".$position."%'";
mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
}


function update($id , $parent = 0 , $name = 0 , $desc = 0 , $icon = 0 ,$group = 0)
{
// lets see if there is a change on the group
if($group == 0){
$this_category = $this->fetch($id);
$group = $this_category['c_group'];
}

// lets get the current position
$position     = $this->get_position($id);
$new_position = $this->get_position($parent).$id.">";

if($position != $new_position){
// then we update all the sub_categories position to be still under the current category
$sql1 = "SELECT id,position
		FROM ".$this->table_name."
		WHERE position	LIKE  '".$position."%'";
$res = mysql_query($sql1) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql1."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

while($sub = mysql_fetch_array($res)){
$new_sub_position = str_replace($position,$new_position,$sub['position']);
$sql2 = "UPDATE ".$this->table_name."
		SET position = '".$new_sub_position."'
		WHERE id =  '".$sub['id']."'";
mysql_query($sql2) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql2."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
}
}
// finally update the category position.
$sql3 = "UPDATE ".$this->table_name."
		SET position = '".$new_position."'
		WHERE position	=  '".$position."'";
mysql_query($sql3) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql3."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

$sql = "UPDATE ".$this->table_name."
		SET ";

// lets see what changes should be done and add it to the sql query.
foreach($this->fields as $field => $field_name){
if ($field 	== 'id') continue;		// no change will be done on the id
if ($field 	== 'position' ) continue; // position change have been done in the section above
$sql .= "".$field_name." = '".$$field."',";
}

$sql = substr_replace($sql,"",-1);
$sql .= "WHERE id=".$id."";

mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
}

function build_list($id=0,$collapsed="") //return an array with the categories ordered by position
{
$RootPos = "";
$this->c_list = array();

if($id != 0){
$this_category  = $this->fetch($id);
$positions      = explode(">",$this_category['position']);
$RootPos        = $positions[0];
}

// lets fetch the root categories
$sql = "SELECT *
		FROM ".$this->table_name."
		WHERE position	RLIKE '^([0-9]+>){1,1}$' AND c_group	=      '".$this->Group."'
		ORDER BY c_name";
$res = mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

while($root = mysql_fetch_array($res)){
$root["prefix"] = $this->get_prefix($root['position']);
$this->c_list[$root['id']] = $root;

	if($RootPos == $root['id'] AND $id != 0 AND $collapsed != ""){
	$this->list_by_id($id);
	continue;

}else{

// lets check if there is sub-categories
	if($collapsed == "" AND $id==0){
	$has_children = $this->has_children($root['position']);
	if($has_children == TRUE) $this->get_children($root['position'],0);
}}}
return $this->c_list;
}

function has_children($position) // return TRUE if that position has sub-categories otherwise returns FALSE
{
$check_sql = "SELECT id FROM ".$this->table_name." WHERE position RLIKE  '^".$position."[0-9]+>$'";
$check_res = mysql_query($check_sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$check_sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
$check = mysql_fetch_array($check_res);
if($check['id'] != "")return TRUE;
else return FALSE;
}

function get_children($position , $id = 0){

$sql = "SELECT *
		FROM ".$this->table_name."
		WHERE position	RLIKE '^".$position."[0-9]+>$'
		ORDER BY c_name";
$res = mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

while($child = mysql_fetch_array($res)){
$child["prefix"] = $this->get_prefix($child['position']);

if($id != 0)
{
$this->c_list_by_id[$child['id']] = $child;
$has_children = $this->has_children($child['position']);
if($has_children == TRUE){
$this->get_children($child['position']);
}
continue;

}else{

// lets check if there is sub-categories
$this->c_list[$child['id']] = $child;
$has_children = $this->has_children($child['position']);
if($has_children == TRUE)$this->get_children($child['position']);
}}
}

function list_by_id($id) //return an array with the categories under the given ID and ordered by name
{
$this_category  = $this->fetch($id);

$positions = explode(">",$this_category['position']);
$pCount = count($positions);
$i = 0;

// lets fetch from top to center
while($i < $pCount){
$pos_id	   = $positions["$i"];
if($pos_id == ""){$i++; continue;}
$list = $this->browse_by_id($pos_id);

foreach($list as $key=>$value){
$this->c_list["$key"] = $value;
$ni = $i + 1;
$nxt_id = $positions[$ni];
if($key == $nxt_id ) break;
} $i++;
}

//center to end
$i = $pCount-1;

while($i >= 0){
$pos_id	 = $positions["$i"];
if($pos_id == ""){$i--; continue;}
$list = $this->browse_by_id($pos_id);

foreach($list as $key=>$value){
$ni = $i - 1;
if($ni < 0) $ni =0;
$nxt_id = $positions[$ni];
if($key == $nxt_id ) break;
$this->c_list["$key"] = $value;
} $i--;
}

}

function browse_by_id($id) // return array of categories under specific category.
{
$children 		= array();
$this_category  = $this->fetch($id);
$position       = $this_category['position'];

$sql = "SELECT *
		FROM ".$this->table_name."
		WHERE position	RLIKE '^".$position."(([0-9])+\>){1}$'
		ORDER BY c_name";
$res = mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

while($child = mysql_fetch_array($res)){
$child["prefix"] = $this->get_prefix($child['position']);
$children[$child['id']] = $child;
}
return $children;
}

function get_position($id)
{
if($id == 0)return "";
$sql = "SELECT position
		FROM ".$this->table_name."
		WHERE id = '".$id."'";
$res = mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
$record =  mysql_fetch_array($res);
return $record['position'];
}

function get_prefix($position)
{
$prefix = "";
$position_slices = explode(">",$position);
$count = count($position_slices) - 1;
for($i=1 ; $i < $count ; $i++){
$prefix .= $this->name_prefix;
}
return $prefix;
}

function fetch ($id)
{
$sql = "SELECT *
		FROM ".$this->table_name."
		WHERE id = '".$id."'";
$res = mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

$record = mysql_fetch_array($res);
$record["prefix"] = $this->get_prefix($record['position']);
$position_slices  = explode(">",$record['position']);
$key              = count($position_slices)-3;
if($key < 0) $key = 0;
$record["parent"] = $position_slices["$key"];
return $record;
}

function html_output($id=0)
{
	 $tree  = $this->build_list($id,"collapsed"); // we have selected to view category


$output = "";
$output .= $this->HtmlTree['header'];

			if(is_array($tree))
			{
				foreach($tree as $c)
				{

					if($c['id'] == $id) 	$body = $this->HtmlTree['BodySelected'];
					else   						  	 	$body = $this->HtmlTree['BodyUnselected'];

					foreach($this->fields as $name => $field_name)
					{
						$body = str_replace("[$name]" ,$c["$field_name"],$body);


					}
						$body = str_replace("[prefix]",$c['prefix'],$body);

				$output .= $body;
				}
			}

$output .= $this->HtmlTree['footer'];
return $output;
}


function count_categories($cat_id)
{
$thisPosition = $this->get_position($cat_id);
$sql = "SELECT *
		FROM ".$this->table_name."
		WHERE position LIKE '".$thisPosition."%'";
$res   = mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
$count = mysql_num_rows($res);
$count-= 1; // remove the category itself from the count
return $count;
}

function count_items($cat_id)
{
if($this->itemsTable == "" OR $this->CID_FieldName=="") die("<br><storng><u>Class Error:</u></strong><br>Either items Table name Or CID field name is blank!<br><br>");

$count = 0;
$thisPosition = $this->get_position($cat_id);

$sql = "SELECT *
		FROM ".$this->table_name."
		WHERE position LIKE '".$thisPosition."%'";
$res = mysql_query($sql) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));

while($category = mysql_fetch_array($res)){

$sql2 = "SELECT *
		FROM ".$this->itemsTable."
		WHERE ".$this->CID_FieldName."	= '".$category["id"]."'";
$res2 = mysql_query($sql2) or die(trigger_error("<br><storng><u>MySQL Error:</u></strong><br>".mysql_error()."<br><br><storng><u>Query Used:</u></strong><br>".$sql."<br><br><storng><u>Info:</u></strong><br>",E_USER_ERROR));
$count+= mysql_num_rows($res2);
}

return $count;
}

} // Class END
?>

kategori.php

<?php error_reporting(E_ALL); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Categories Class Test .. By Shadi Ali</title>
<style>
.code_div{
border:dashed #006600 1px;
background:#E8FFEB;
font-family:Georgia, "Times New Roman", Times, serif;
font-size:11px;
width:90%;
padding:5px;
}
</style>
</head>
<body style="font-family:Tahoma">
<p>
  <?php


// connect to database
mysql_connect("localhost","root","");
mysql_select_db("testing");

require_once("categories.class.php");

// Simple Usage
if(!isset($_GET["id"])) $_GET["id"] =0;

$ctg_id = $_GET["id"];

$categories = new categories;
	$categories->name_prefix = "&nbsp;&nbsp;";

	?>
</p>
<p>Here is it a Html Menu:</p>
<br>
<div class="code_div"> <code><font color="#000000"><font color="#0000bb">$categories </font><font color="#007700">= new </font><font color="#0000bb">categories</font><font color="#007700">; </font></font><br><font color="#000000"><font color="#ff8000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000bb">$output &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#007700">= </font><font color="#0000bb">$categories</font><font color="#007700">-&gt;</font><font color="#0000bb">html_output</font><font color="#007700">(</font><font color="#0000bb">$ctg_id</font><font color="#007700">); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#0000bb">$output</font><font color="#007700">;</font></font></code> </div>
<p>  
  <?
	// lets display the categories
		
		$output 		 = $categories->html_output($ctg_id);
		echo $output;	
	?>
</p>
<hr>
<p>now I'll modify the $HtmlTree value a bit.</p>
<div class="code_div"> <code><font color="#000000"><font color="#0000bb">$categories</font><font color="#007700">-&gt;</font><font color="#0000bb">HtmlTree </font><font color="#007700">= array( <br>
</font><font color="#dd0000">"header" </font><font color="#007700">=&gt; </font><font color="#dd0000">"&lt;table width=200px border=0 cellpadding=2 cellspacing=2&gt;"</font><font color="#007700">, <br>
</font><font color="#dd0000">"BodyUnselected" </font><font color="#007700">=&gt; </font><font color="#dd0000">'&lt;tr&gt;&lt;td  bgcolor=#C4D9FD &gt;[prefix]&amp;raquo;&lt;a  href="?id=[id]"&gt;&lt;font  color=#53507A&gt;[name]&lt;/font&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;'</font><font color="#007700">, <br>
</font><font color="#dd0000">"BodySelected" </font><font color="#007700">=&gt; </font><font color="#dd0000">'&lt;tr&gt;&lt;td  bgcolor="#E4DB2C"&gt;[prefix]&amp;bull;&lt;a  href="?id=[id]"&gt;&lt;strong&gt;&lt;font  color="#000000"&gt;[name]&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;'</font><font color="#007700">, <br>
</font><font color="#dd0000">"footer" </font><font color="#007700">=&gt; </font><font color="#dd0000">'&lt;/table&gt;'</font><font color="#007700">, <br>
); <br>
<br>
</font><font color="#0000bb">$output </font><font color="#007700">= </font><font color="#0000bb">$categories</font><font color="#007700">-&gt;</font><font color="#0000bb">html_output</font><font color="#007700">(</font><font color="#0000bb">$ctg_id</font><font color="#007700">); <br>
echo </font><font color="#0000bb">$output</font><font color="#007700">; </font></font></code> </div>


<?php

$categories->HtmlTree = array(
"header" => "<table width=200px border=0 cellpadding=2 cellspacing=2>", 
"BodyUnselected" => '<tr><td bgcolor=#C4D9FD >[prefix]&raquo;<a href="?id=[id]"><font color=#53507A>[name]</font></a></td></tr>',
"BodySelected" => '<tr><td bgcolor="#E4DB2C">[prefix]&bull;<a href="?id=[id]"><strong><font color="#000000">[name]</font></strong></a></td></tr>',
"footer" => '</table>',
);

$output = $categories->html_output($ctg_id); 
echo $output;
?>
	<hr>
	<?
	
	// lets get an array of the categories for our works
$categories = new categories;
	$categories_list = $categories->build_list();
	
// lets do some actions
if(!isset($_REQUEST['act'])) $_REQUEST['act'] = "";

$act     = $_REQUEST["act"];

switch($act)
{
	case "add":
	
		// lets add new category
		//  $categories->add_new( category parent ,  category name , description , icon path , group )

		$categories->add_new($_POST['parent'] , $_POST["name"] , $_POST["desc"] , $_POST["icon"] );
		echo '<script>alert("Category was inserted successfully into database");
		 	 location="class_categories_test.php";	
	  		</script>';
	break;
	
	case "delete":
		$categories->delete($_GET["id"]);
			echo '<script>alert("Category and Sub-Categories was successfully deleted");
		 	 location="class_categories_test.php";	
	  		</script>';
	
	break;
	
	case "_update":
		$cat = $categories->fetch($_GET["id"]);
		
		?>
		<form name="form1" method="post" action="">
          <p> the form below will execute the following. <br>
</p>
          <div class="code_div"> <code><font color="#000000"><font color="#007700">&nbsp;</font><font color="#0000bb">$categories</font><font color="#007700">-&gt;</font><font color="#0000bb">update</font><font color="#007700">(</font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"id"</font><font color="#007700">] , </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"parent"</font><font color="#007700">] , </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"name"</font><font color="#007700">] , </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"desc"</font><font color="#007700">] , </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"icon"</font><font color="#007700">] );</font></font></code> </div>
          <br>
          <table width="90%"  border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <td colspan="3"><div align="center">Edit Category </div></td>
    </tr>
    <tr>
      <td width="13%">Child Of : </td>
      <td width="1%">:</td>
      <td width="86%">
	  <select name="parent" id="parent">
        <option value="0" selected>ROOT</option>
		<?
		foreach($categories_list as $c)
		{
			if($cat["id"] == $c["id"]) continue; // we don't list the category to be child of itself !!
			?>
			<option value="<?=$c["id"]?>" <? if($c["id"] == $cat["parent"]) echo "selected"; ?> ><?=$c["prefix"]?>&raquo;<?=$c["c_name"]?></option>
			<?	
		}
		?>
      </select>
	  </td>
    </tr>
    <tr>
      <td>Name:</td>
      <td>:</td>
      <td><input name="name" type="text" id="name" value="<?=$cat["c_name"]?>" size="20"></td>
    </tr>
    <tr>
      <td>Description:</td>
      <td>:</td>
      <td><textarea name="desc" cols="40" rows="3" id="desc"><?=$cat["c_desc"]?>
      </textarea></td>
    </tr>
    <tr>
      <td>Icon:</td>
      <td>:</td>
      <td><input name="icon" type="text" id="icon" value="<?=$cat["c_icon"]?>" size="30"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">
        <input name="act" type="hidden" value="update">
		<input name="id" type="hidden" value="<?=$ctg_id?>">
		<input type="submit" name="Submit" value="Save">
      </div></td>
    </tr>
  </table>
</form>
		 <?
		 die();
		
	break;
	
	case "update":
		$categories->update($_POST["id"] , $_POST["parent"] , $_POST["name"] , $_POST["desc"] , $_POST["icon"] );
		
		echo '<script>alert("Category was updated successfully!");
		 	 location="class_categories_test.php";	
	  		</script>';
	break;
	
}


	
?>
		
         <p align="center">&nbsp;</p>
         <p align="center"><strong>You may list all your categories expanded like this</strong></p>
<div class="code_div">
  <code><font color="#000000"><font color="#0000bb">$categories </font><font color="#007700">= new </font><font color="#0000bb">categories</font><font color="#007700">; <br>
  &nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000bb">$categories_list </font><font color="#007700">= </font><font color="#0000bb">$categories</font><font color="#007700">-&gt;</font><font color="#0000bb">build_list</font><font color="#007700">(0);</font></font></code>
  <br>// $categories_list is now an array and you should use foreach command to print something like the following list.
</div>
        <br>
         <table width="90%"  border="0" align="center" cellpadding="2" cellspacing="0">
		<tr>
			<td bgcolor="#4180BE"><font color="#FFFFFF"><strong>
			Categories List:
			</strong></font></td>
		</tr>
		<?
			foreach($categories_list as $c)
			{
				?>
				
				<tr>
					<td>
					
					<?=$c["prefix"]?>&raquo;<?=$c["c_name"]?> - [<a href="?act=_update&id=<?=$c["id"]?>">Edit</a> - <a href="?act=delete&id=<?=$c["id"]?>">Delete</a>]
					</td>
				</tr>
				
				<?
			}
		?>
		</table>
		


<p align="center">&nbsp;</p>
<p align="center"><strong>Or you may also use it in a combo box</strong></p>
<table width="0" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td width="72"><select name="category_id" id="category_id">
    
      <?
		foreach($categories_list as $c)
		{
			?>
			 <option value="<?=$c["id"]?>"><?=$c["prefix"]?>&raquo;<?=$c["c_name"]?> </option>
      <?	 
		}
		?>
            </select></td>
    <td width="0"><input type="button" name="Button" value="Edit" onClick="location='class_categories_test.php?act=_update&id='+document.getElementById('category_id').value;"></td>
    <td width="0"><input type="button" name="Button" value="Delete" onClick="location='class_categories_test.php?act=delete&id='+document.getElementById('category_id').value;"></td>
  </tr>
</table>
<p>&nbsp; </p>
<p><hr></p>
<form name="form1" method="post" action="">
 the form below will execute the following.
  <br>
<div class="code_div">
  <code><font color="#000000"><font color="#ff8000">&nbsp;</font><font color="#0000bb">$categories</font><font color="#007700">-&gt;</font><font color="#0000bb">add_new</font><font color="#007700">(</font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">'parent'</font><font color="#007700">] , </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"name"</font><font color="#007700">] , </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"desc"</font><font color="#007700">] , </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">"icon"</font><font color="#007700">] ); </font></font></code></div><br>
  <table width="400"  border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <td colspan="3" bgcolor="#4180BE"><div align="center"><strong><font color="#FFFFFF">Add New Category </font></strong></div></td>
    </tr>
    <tr>
      <td width="13%">Child Of : </td>
      <td width="1%">:</td>
      <td width="86%"><select name="parent" id="parent">
        <option value="0">ROOT</option>
        <?
		foreach($categories_list as $c)
		{
			?>
        <option value="<?=$c["id"]?>"  >
        <?=$c["prefix"]?>&raquo;<?=$c["c_name"]?>
        </option>
        <?	
		}
		?>
      </select></td>
    </tr>
    <tr>
      <td>Name:</td>
      <td>:</td>
      <td><input name="name" type="text" id="name" size="20"></td>
    </tr>
    <tr>
      <td>Description:</td>
      <td>:</td>
      <td><textarea name="desc" cols="40" rows="3" id="desc"></textarea></td>
    </tr>
    <tr>
      <td>Icon:</td>
      <td>:</td>
      <td><input name="icon" type="text" id="icon" value="http://" size="30"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">
        <input name="act" type="hidden" value="add">
        <input type="submit" name="Submit" value="Add">
      </div></td>
    </tr>
  </table>
 
</form>

<p align="center">&nbsp;</p>

</body>
</html>
menu kodları
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<STYLE type=text/css>#wrapper {
	BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 0.8em; BORDER-BOTTOM-WIDTH: 0px; MARGIN: 0px auto; WIDTH: 260px; FONT-FAMILY: Calibri, Tahoma, Arial, sans-serif; BORDER-RIGHT-WIDTH: 0px
}
</STYLE>
<LINK media="all" href="p7TMM06.css" type="text/css" rel="stylesheet">
<SCRIPT src="p7TMMscripts.js" type="text/javascript"></SCRIPT>
<BODY>
<DIV id=wrapper>
<DIV class=p7TMM06 id=p7TMM_1>
<UL class=p7TMM>
<LI><A href="#">Root Menu Item</A> 
<DIV>
  <UL>
    <LI><A href="#">Menu Item</A>
	<LI><A href="#">Menu Item</A></LI>
	</UL>
	</DIV>
  <LI><A href="#">Root Menu Item</A><DIV>
  <UL>
    <LI><A href="#">Sub-Menu Item</A>
	<LI><A href="#">Menu Item</A> 
<DIV><UL>
<LI><A href="#">Menu Item</A>
<LI><A href="#">Menu Item</A>
<LI><A href="#">Menu Item</A>
</LI></UL></DIV>
    <LI><A href="#">Sub-Menu Item</A><LI><A 
    href="#">Sub-Menu Item</A> </LI></UL></DIV>
  <LI><A href="#">Root Menu Item</A> 
  <DIV>
  <UL>
    <LI><A href="">Current Mark</A> 
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu Item</A> </LI></UL></DIV>
  <LI><A href="#">Root Menu Item</A> 
  <DIV>
  <UL>
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu Item</A></LI></UL></DIV>
	
	 <LI><A href="#">Root Menu Item</A> 
  <DIV>
  <UL>
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu item</A> </LI></UL></DIV>

	 <LI><A href="#">Root Menu Item</A> 
  <DIV>
  <UL>
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu Item</A> </LI></UL></DIV>
	
	
	 <LI><A href="#">Root Menu Item</A> 
  <DIV>
  <UL>
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu Item</A> </LI></UL></DIV>
	
	
	 <LI><A href="#">Root Menu Item</A> 
  <DIV>
  <UL>
    <LI><A href="#">Menu Item</A> 
    <LI><A href="#">Menu 
    Item</A> 
    <LI><A href="#">Menu Item</A> </LI></UL></DIV>
	</LI></UL>
<SCRIPT type=text/javascript>
<!--
P7_TMMop('p7TMM_1',3,0,0,3,1,1,1,1,-1,150);
//-->
  </SCRIPT>
</DIV></DIV></DIV></BODY></HTML>

kodları bunlar css ve js dosyasıda var..