Jump to content

Need help with a dropdown menu.


sydd

Recommended Posts

First of all, hi!

I've got a little problem with my coding, specifically I'd like to create a dropdown menu in my php code.

 

Let me try to explain what I'm trying to do:

 

I've got a menu on the left, displaying links to 6 projects of ours. When you reach each project site, you can select different sub-pages (team, contact, downloads, etc...). What I'd like to do is simplify the process by adding a dropdown sub-menu to each project. Meaning when I hover with the mouse over project number 1, there's a nifty little box that suddenly appears to the right displaying the different sub-menus. With me so far? Good! I suck at explaining. ;p

 

I've been playing around with <ul> and <li> for  acouple of days and somehow I always get the same error message when I try, syntax error on line 7172 unexpected T_somethingorother. Anyway, I digress, here's the code:

 

function getProjectList($strFieldName){
		global $conf;
		$db = new AGDBConnection();
		$rs = new AGDBRecordset();
		$f = new AGFunctionsLib();
		$dbo = $db->init($conf['dsn']);
		$strCurrLang = $_COOKIE['strCurrLang'];
		if($strFieldName=='pr_name'){

				$sql = "select * from projects where pr_status=1 and pr_lang= '".$f->getCurrentLanguage()."' order by pr_ID DESC";


			$rs->query($sql,$dbo);

			if($rs->getNumRows() > 0){
				$intProjectCount = 1;
				$htmlOut ="<table width='100%'  border='0' align='center' cellpadding='1' cellspacing='0'>";
				foreach($rs->fetch() as $prs){

			        $htmlOut .="<tr><td class=\"projectkiri\" ><a href=\"/index.php?page=PROJECTS&id=".$prs['pr_ID']."\">".$prs[$strFieldName]."</a></td></tr>";
			        $intProjectCount++;
				}
				 $htmlOut .="</table>";
			}else{
				$htmlOut ="<table width='100%'  border='0' align='center' cellpadding='1' cellspacing='0'>";
				$htmlOut .="<tr>
			            <td class='projectkiri'>Belum ada proyek <br>untuk saat ini</td>
			          </tr>
			        </table>";
			}
			}

 

"projectkiri" being project to the left. Basically it's the left-side menu where I'd like to add dropdown-menus. :P

 

If you guys need anything else or if I wasn't clear enough, I'd be more than happy to provide you with any additional information you need.

 

Thanks in advance.

 

 

Link to comment
Share on other sites

I'm sorry to sound condescending.. but there should be absolutely NO reason to have 7000 lines of code in 1 file...

 

also.. what you'd want to do is create a div somewhere in the body.. set it to display: none; in the css.. and make it position: absolute; and then set up mouse over events and use the target element's (the link's) offsetX and offsetY and width attributes to judge where to place the floating div.. and in the function set the floating div to display: block; set the top and left attributes to the correct pixel coordinates, and then make sure u set the width and the height coz position: absolute will rip it off the page and remove its width and height (last time I checked anyway)

 

good luck :).. its fairly easy actually, you should be able to manage it

Link to comment
Share on other sites

I'm sorry to sound condescending.. but there should be absolutely NO reason to have 7000 lines of code in 1 file...

 

also.. what you'd want to do is create a div somewhere in the body.. set it to display: none; in the css.. and make it position: absolute; and then set up mouse over events and use the target element's (the link's) offsetX and offsetY and width attributes to judge where to place the floating div.. and in the function set the floating div to display: block; set the top and left attributes to the correct pixel coordinates, and then make sure u set the width and the height coz position: absolute will rip it off the page and remove its width and height (last time I checked anyway)

 

good luck :).. its fairly easy actually, you should be able to manage it

 

It's actually 8489 lines of code. :D It's the functions library, and pretty much the only place where I can edit that particular snippet of code (I THINK, like.. 95% sure).

 

I'm fairly new to php, the guy that designed our website was hired by an outside contractor who went bankrupt a while back and now we can't seem to find whoever wrote this bs. So now it's up to me (yay) to change whatever needs changing on the website.

 

I'll try with the div, but like I said, fairly new to coding. :P

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.