Jump to content

Slashdot Menu Database Integration Problems


googlit

Recommended Posts

Hi all,

 

Heres my problem....

 

i have created a script that will run a category tree on my webpage and am wanting to integrate it into an existing java menu call slashdot (sdmenu).

 

I have no idea where to start so was looking for some assistance...

 

DB Setup:

 

Column----- Type------------- NULL Default

id------------- int(11)------------ No ----------------------auto Increment - Primary Key

name ------ Varchar(255)--- No

parent_id --- int(11)------------ No ------0

catDescrip-- varchar(255)-- YES -----NULL

catOrder --- varchar(255) - YES ---- NULL

isActive ------int(11) ----------- NO ------1

 

 

My Code for the category tree is as follows:

 

<?php
function hasChild($parent_id)
{
$sql = "SELECT COUNT(*) as count FROM categories WHERE parent_id = '" . $parent_id . "'";
$qry = mysql_query($sql);
$rs = mysql_fetch_array($qry);
return $rs['count'];
}
function CategoryTree($list,$parent,$append)
{
$list = '<li>'.$parent['name'].'</li>';
if (hasChild($parent['id'])) // check if the id has a child
{
	 $append++;
	 $list .= "<ul class='child child".$append."'>";
	 $sql = "SELECT * FROM categories WHERE parent_id = '" . $parent['id'] . "'";
	 $qry = mysql_query($sql);
	 $child = mysql_fetch_array($qry);
	 do{
	 $list .= CategoryTree($list,$child,$append);
	 }while($child = mysql_fetch_array($qry));
	 $list .= "</ul>";
}
return $list;
}
function CategoryList()
{
$list = "";
$sql = "SELECT * FROM categories WHERE (parent_id = 0 OR parent_id IS NULL)";
$qry = mysql_query($sql);
$parent = mysql_fetch_array($qry);
$mainlist = "<ul class='parent'>";
do{
	 $mainlist .= CategoryTree($list,$parent,$append = 0);
}while($parent = mysql_fetch_array($qry));
$list .= "</ul>";
return $mainlist;
}
?>

 

 

and the code i am wanting to place it into is as follows:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="sdmenu/sdmenu.css" />
    <script type="text/javascript" src="sdmenu/sdmenu.js">

    </script>
    <script type="text/javascript">
    // <![CDATA[
    var myMenu;
    window.onload = function() {
		    myMenu = new SDMenu("my_menu");
		    myMenu.init();
    };
    // ]]>
    </script>
</head>
<body>
<!--Navbar test--------------------->

<div style="float: left" id="my_menu" class="sdmenu">
	  <div>
		    <span>one</span>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
	  </div>
	  <div>


		    <span>two</span>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
	  </div>
	  <div class="collapsed">


		    <span>three</span>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
	  </div>
	  <div>


		    <span>four</span>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
		    <a href="link1.php">link1</a>
	  </div>
    </div>

</body>
</html>

 

a preview of the menu can be seen here:

 

http://www.iwdmachines.co.uk/sd/

 

 

attached are the files for SDMENU

sdmenu.zip

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.