Hyperlinks in drop down menu

I can’t yet due to sensitive nature of beta project. I do appreciate your help though. I have an index page that pulls in the nav page, header page, etc. One of those pages is the page that pulls items into the dropdown menu. I don’t know if I should put the script part in the index page or somehow in the actual page that the dropdown menu php is on. Thanks again.

You can email me what you have and I’ll take a look at it tomorrow, if I get time. Just use the mail icon next to my name to send it to me.

By the way, the new redesign of phphelp.com looks pretty good!

Here is the code for the index page (that pulls in the linked page with the problem):

[php]<?php
session_start();
?>

thankyou <?php include("mylibrary/login.php"); include("mylibrary/showproducts.php"); include("mylibrary/showproducts2.php"); include("mylibrary/showproducts3.php"); include("mylibrary/showproducts4.php"); include("mylibrary/showproducts5.php"); login(); ?>
<?php include("mobileheader.inc.php"); ?>
<?php include("nav.inc.php"); ?>
<?php include("footer.inc.php"); ?>
[/php]

And the issue is on the nav page. I list the departments now in a column with hyperlinks. This long list runs off the page. I’m trying to convert this list of departments into a dropdown menu list with hyprlinks. Here is the code for the nav page that I have working as a column:

[php] <?php
$query=“SELECT catid,name from categories ORDER BY catid”;
$result=mysql_query($query);
while($row=mysql_fetch_array($result,MYSQL_ASSOC))
{
$catid = $row[‘catid’];
$name = $row[‘name’];
$query2=“SELECT count(prodid) FROM products WHERE catid = $catid”;
$result2 = mysql_query($query2);
$row=mysql_fetch_array($result2);
$total = $row[0];
echo “<a href=“index.php?content=buyproducts&cat=$catid”>$name ($total)
\n”;
}
?>
[/php]

Any help is appreciated. If you will, let me know where to put any edits. For example, I have tried to put scripting in the head section of the index page as well as just prior to the php on the nav page. None seems to work right for me. I have researched this on the Internet and in my php/mysql/apache book but can’t seem to find a solution that works. Thanks again.

Give this a try…

[php]

<?php $query="SELECT catid,name from categories ORDER BY catid"; $result=mysql_query($query); echo ''; while($row=mysql_fetch_array($result,MYSQL_ASSOC)) { $catid = $row['catid']; $name = $row['name']; $query2="SELECT count(prodid) FROM products WHERE catid = $catid"; $result2 = mysql_query($query2); $row=mysql_fetch_array($result2); $total = $row[0]; echo '' . $name . '(' . $total . ')'; } echo ""; ?>[/php]

Thank you very much. That’s the look I wanted. Thanks again!

So it looks great but I can’t get the hyperlink part to work. I click on an item in the dropdown and nothing happens…back to the same page with the dropdown. Any advice? Thx

Make sure you have the Javascript I posted in your code. If you are using Chromr or FireFox access developer tools java console and take a look to make sure their are no errors.

Everything looks clean. I don’t see any hyperlink mechanism in this code. I’m not that familiar with your method, so I might be missing something. Thx

The onchange event in the select below, fires off the javascript…

[php] echo ‘’;[/php]

This is the javascript, it changes the window.location to the value in the option.

[php][/php]

Yeah, I just figured that out. Thanks. I think the problem is in the last echo line before the

I have replaced cat with catid and id but nothing…

Thoughts?

As soon as that window.location fires, it should change your url. Does that happen?

Oddly enough, it does…? But the page is the same… The catid changes in the url. Just like it should. But the page itself stays the same.

that’s because you’re telling it to go to the index.php page everytime…

[php]value="index.php?content=buyproducts&cat=[/php]

Changing the catid, just changes the querystring parameter… It doesn’t change the page it’s calling.

But it worked before. I have the index page set up to have a header, footer and main section. The main section is the part that changes when a hyperlink is selected from the dropdown. It pulls in the buyproducts page with the products displayed instead of the main section now that has the dropdown menu in it…

It probable does something different based on the querystring…

Is there any $_GET[‘Cat’] ir $_GET[‘CatID’] or $_POST?

[php]<?php
$catid = $_GET[‘cat’];

$query=“SELECT name from categories WHERE catid = $catid”;
$result = mysql_query($query);
$row=mysql_fetch_array($result, MYSQL_ASSOC);
echo “

<font color=>
{$row[‘name’]} - Click here

\n”;

if (!isset($_GET[‘page’]))
$page = 1;
else
$page = $_GET[‘page’];

showproducts($catid, $page, “index.php?content=buyproducts”, “index.php?content=updatecart”);
?>[/php]

[php] $catid = $_GET[‘cat’];[/php]

Then you should leave it as cat!

It is cat, just not jumping to the hyperlinked page. Thanks. May sign off for the night shortly. Thanks again.

It is jumping to the right page index.php, it’s just not getting falling into the right area in the index.php to trigger the code you want, if you posted all your code I can be of more help.

Okay. And thanks to you guys helping so far. I have the layout of the items in the drop down menu. But when I select one, the page does not change.

This is buyproducts.inc.php

[php]<?php
$catid = $_GET[‘cat’];

$query=“SELECT name from categories WHERE catid = $catid”;
$result = mysql_query($query);
$row=mysql_fetch_array($result, MYSQL_ASSOC);
echo “

<font color=>
{$row[‘name’]} - Click to learn more

\n”;

if (!isset($_GET[‘page’]))
$page = 1;
else
$page = $_GET[‘page’];

showproducts($catid, $page, “index.php?content=buyproducts”, “index.php?content=updatecart”);
?>[/php]

This is index.php

[php]<?php
session_start();
?>

hidden <?php include("mylibrary/login.php"); include("mylibrary/showproducts.php"); include("mylibrary/showproducts2.php"); include("mylibrary/showproducts3.php"); include("mylibrary/showproducts4.php"); include("mylibrary/showproducts5.php"); login(); ?>
<?php include("mobileheader.inc.php"); ?>
<?php include("main.inc.php"); ?>
<?php include("footer.inc.php"); ?>
[/php]

And this is the nav.inc.php page that contains the links in the drop down menu that don’t make the page change that causes my main issue now. Thanks for all your help!

[php]

<?php $query="SELECT catid,name from categories ORDER BY name"; $result=mysql_query($query); echo ''; while($row=mysql_fetch_array($result,MYSQL_ASSOC)) { $catid = $row['catid']; $name = $row['name']; $query2="SELECT count(prodid) FROM products WHERE catid = $catid"; $result2 = mysql_query($query2); $row=mysql_fetch_array($result2); $total = $row[0]; echo '' . $name . '(' . $total . ')'; } echo ""; ?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service