Hyperlinks in drop down menus

Would anyone have any samples of code that includes hyperlinks to the items in a drop down menu? I have scoured the web and can’t find any that works without jquery. Any help is appreciated. Thanks.

Here is the code that works:

index file

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

<?php include("mylibrary/login.php"); include("mylibrary/showproducts.php"); include("mylibrary/showproducts2.php");

login();
?>

<?php include("header.inc.php"); ?>
<?php include("nav.inc.php"); ?> <?php if (!isset($_REQUEST['content'])) include("main.inc.php"); else { $content = $_REQUEST['content']; $nextpage = $content . ".inc.php"; include($nextpage); } ?> <?php include("rightsidenav.inc.php"); ?>
<?php include("footer.inc.php"); ?>
[/php]

here is the main page

[php]

Items on SPECIAL today:

<?php $query = "SELECT * from products where onsale = TRUE"; $result = mysql_query($query); echo "\n"; while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $prodid = $row['prodid']; $description = $row['description']; $price = $row['price']; $entreename = $row['entreename']; $restname = $row['restname']; $custid = $row['custid']; echo "\n"; } echo "
\n"; echo ""; echo " \n"; echo ""; echo "$entreename\n"; echo " \n"; echo ""; echo "$restname\n"; echo " \n"; printf("$%.2f\n", $price); echo " \n"; echo "
\n"; ?>[/php]

here is the nav page

[php]

Homepage

Browse specials:

<?php $query="SELECT catid,name from categories"; $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 "$name ($total)
\n"; } ?>
[/php]

here is buyproducts

<?php $catid = $_GET['cat']; $query="SELECT name from categories WHERE catid = $catid"; $result = mysql_query($query); $row=mysql_fetch_array($result, MYSQL_ASSOC); echo "


{$row['name']} - Click a special 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"); ?>

here is showproducts

[php]

<?php function showproducts($catid, $page, $currentpage, $newpage) { $query = "Select count(prodid) from products where catid = $catid"; $result = mysql_query($query); $row = mysql_fetch_array($result); if ($row[0] == 0) { echo "


Sorry, there are no items in this category\n"; } else { $thispage = $page; $totrecords = $row[0]; $recordsperpage = 5; $offset = ($thispage - 1) * $recordsperpage; $totpages = ceil($totrecords / $recordsperpage); echo "

\n"; //echo "\n"; //echo "\n"; //echo "\n"; //echo "\n"; //echo "\n"; //echo "\n"; //echo "\n"; $query = "SELECT * from products WHERE catid=$catid LIMIT $offset,$recordsperpage"; $result = mysql_query($query); while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $prodid = $row['prodid']; // $description = $row['description']; $description = substr(stripslashes($row['description']), 0, 25); $price = $row['price']; // $name = $row['entreename']; $name = substr(stripslashes($row['entreename']), 0, 15); $onsale = $row['onsale']; //-----------------------------------starts records display--------first row--- echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; //------end of first column in first row----------- } // Code to implement paging if ($thispage > 1) { $page = $thispage - 1; $prevpage = "Previous page"; } else { $prevpage = " "; } if ($thispage < $totpages) { $page = $thispage + 1; $nextpage = " Next page"; } else { $nextpage = " "; } if ($totpages > 1) echo $prevpage . " " . $nextpage; echo "
ImageNamePriceCompanyPhoneDescriptionSpecial


$name$ $price
\n"; echo "
$description

$restname
$restphone

\n"; } } ?>[/php]

That’s cause you can’t have a hyperlink in a dropdown, period. If you want to have a selection go to a specific URL as soon as you make the selection then you would need to use JavaScript or jquery to do that. Jquery is certainly the easiest way to do it.

So the code works fine but the list of items is displayed in a vertical nav bar on the left side of the index page. I need all those items incorporated into a dropdown menu with the hyperlink capability working, not just listed. Any help is appreciated.

But I am told that it can be done. The mechanism is different somehow. I have just never seen it ANYWHERE without jquery. Thanks. BTW I don’t want jquery because I don’t know how to code in jquery, not because I think it is a bad way to go.

Sponsor our Newsletter | Privacy Policy | Terms of Service