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();
?>
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"); ?>
|
here is the main page
[php]
Items on SPECIAL today:
<?php
$query = "SELECT * from products where onsale = TRUE";
$result = mysql_query($query);
echo "\n";
echo " |
\n"; echo ""; echo "$entreename\n"; echo " | \n"; echo ""; echo "$restname\n"; echo " | \n"; printf("$%.2f\n", $price); echo " | \n"; echo " |
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"; } ?> |
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 "
Image | \n"; //echo "Name | \n"; //echo "Price | \n"; //echo "Company | \n"; //echo "Phone | \n"; //echo "Description | \n"; //echo "Special |
$name$ $price \n"; echo " |
$description $restname $restphone |
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.