PHP - Updating A Dynamic Menu Problem
I'm trying to figure it out why my code it's only updating the last menu or submenu of a menu. The menu and submenu are stored in the same database and the parent_id is equal to the id for the sub-menus . Parent_id = 0 means it's a main menu. Help!
Similar TutorialsHey guys, I got another one that i could use some help on. I have a input form that utilizes a javascript that adds additional rows to my table. here is a look at what i got. Code: [Select] <script type="text/javascript"> function insertRow() { var x = document.getElementById('results_table').insertRow(-1); var a = x.insertCell(0); var b = x.insertCell(1); var c = x.insertCell(2); var d = x.insertCell(3); var e = x.insertCell(4); a.innerHTML="<input type=\"text\" name=\"id\">"; b.innerHTML="<input type=\"text\" name=\"place\">"; c.innerHTML="<input type=\"text\" name=\"username\">"; d.innerHTML="<input type=\"text\" name=\"earnings\">"; e.innerHTML="<input type=\"button\" value=\"delete\" onClick=\"deleteRow(this)\">"; } function deleteRow(r) { var i=r.parentNode.parentNode.rowIndex; document.getElementById('results_table').deleteRow(i); } </script> this is my code stored in the header of my page. basically just a button to add a new row and a button in each row to delete rows if needed. here is a look at my html table, pretty basic... Code: [Select] <table id="results_table"> <th>Event ID</th><th>Place</th><th>Username</th><th>Earnings</th> <tr> <td><input type="text" name="id"></td><td><input type="text" name="place"></td><td><input type="text" name="username"></td><td><input type="text" name="earnings"></td><td><input type="button" value="delete" onClick="deleteRow(this)"</td> </tr> </table> Now what I am hoping to acheive is once i submit all of these rows to the database i will insert each of these rows into their own row in the database. is this doable? the structure of my database is: ResultID (Primary Key) Place Earnings UserID (Foreign Key) EventID (Foreign Key) now i think the biggest problem i'm having with submitting data to the database is that in the original HTML form I am typing in the actual username and not the userID. so when it comes to processing I need to do a switch of these two things before I run my query. Should something like this work? Code: [Select] $username = $_POST['username']; $userID = "SELECT userID FROM users WHERE username="$username"; $query = mysql_query($userID); also i've never tried to submit multiple entries at a time. maybe i have to create an array somehow in order to capture each rows data. any thoughts? as always thanks for the help. Hello,, I have looked for numerous examples, and have only got part of the answer. I have successfully populated a drop down list by reading the database. It populates with a list of quest titles. Once the user selects the quest. I want a textbox to populate with the Quest Description. I found an example that uses AJAX/PHP to do this, but it doesn't access a db to read/populate. The main code is in index.html The original example you select a country, and it populates a text field with the currency code. It passes a variable called $country to another file called find_ccode.php. I changed the first case in find_ccode.php to access my database, and populate the text box with quest description. Ideally I will like to make this case dynamic based off QuestID, would populate textbox with corresponding Quest Description (QDescrip). I then tried the other way in index.php I dynamically populated the dropdown list, and gave the option values the QuestIDs to be passed to $country, but something isn't working. I have a write files command to let me know what the $country variable is passing, and it never writes. It works in index.html though. I apologize in advance for my amateurish coding. I still have a lot to learn. I have included the code below, but if you know a more elegant way of doing it. I am creating a role-playing game, as you probably have figured out by now. I hope to one day put it on the web, but right now using it as a way of learning html, and PHP. I really want to know how to catch the value of the dropdown box. I would like to know what it is before sending over. also what is this.value. I assume this is what the value of the dropdown box is when you have selected something. I have been beating my head for days trying to figure this out. Any help is very much appreciated! Index.html <html> <head> <title>Changing textbox value based on dropdown list using Ajax and PHP</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script> // Developed by Roshan Bhattarai // Visit http://roshanbh.com.np for this script and more. // This notice MUST stay intact for legal use //fuction to return the xml http object function getXMLHTTP() { var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getCurrencyCode(strURL) { var req = getXMLHTTP(); if (req) { //function to be called when state is changed req.onreadystatechange = function() { //when state is completed i.e 4 if (req.readyState == 4) { // only if http status is "OK" if (req.status == 200) { document.getElementById('cur_code').value=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script> </head> <body style="font: 12px Verdana, Arial, Helvetica, sans-serif;"> <form style="text-align:center" method="post" action="" name="form1"> <p style="color:#000099 ">When you change the dropdown list, the respective currency code of the country will be displayed in the textbox which is fetched from PHP using Ajax. </p> <p>Country : <select name="country" onChange="getCurrencyCode('find_ccode.php?country='+this.value)" <?php mysql_connect('localhost', '$user', '$password'); mysql_select_db('sok'); $result = mysql_query('select QuestID,QTitle, QDescrip from QuestList'); $options=""; while ($row=mysql_fetch_array($result)) { $QuestID=$row["QuestID"]; $QTitle=$row["QTitle"]; $options.="<OPTION VALUE=\"$QuestID\">".$QTitle; } ?> <option value="">Select Country</option> <option value="1">USA</option> <option value="2">UK</option> <option value="3">Nepal</option> </select><br/><br/> Currency : <input type="text" name="cur_code" id="cur_code" ></p> </form> </body> </html> Index.php <html> <head> <title>Changing textbox value based on dropdown list using Ajax and PHP</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script> // Developed by Roshan Bhattarai // Visit http://roshanbh.com.np for this script and more. // This notice MUST stay intact for legal use //fuction to return the xml http object function getXMLHTTP() { var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getCurrencyCode(strURL) { var req = getXMLHTTP(); if (req) { //function to be called when state is changed req.onreadystatechange = function() { //when state is completed i.e 4 if (req.readyState == 4) { // only if http status is "OK" if (req.status == 200) { document.getElementById('cur_code').value=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script> </head> <body style="font: 12px Verdana, Arial, Helvetica, sans-serif;"> <form style="text-align:center" method="post" action="" name="form1"> <p style="color:#000099 ">When you change the dropdown list, the respective currency code of the country will be displayed in the textbox which is fetched from PHP using Ajax. </p> <p>Quest : <select name="country" getCurrencyCode('find_ccode.php?country='+this.value)">' <?php mysql_connect('localhost', '$user', '$password'); mysql_select_db('sok'); $result = mysql_query('select QuestID,QTitle, QDescrip from QuestList'); $options=""; while ($row=mysql_fetch_array($result)) { $QuestID=$row["QuestID"]; $QTitle=$row["QTitle"]; $options.="<OPTION VALUE=\"$QuestID\">".$QTitle; } $myFile = "test_catchoption.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $options); fclose($fh); ?> Choose your Quest <?=$options?> </SELECT> <br/><br/> Quest Description : <input type="text" name="cur_code" id="cur_code" ></p> </form> </body> </html> find_ccode.php <?php // Developed by Roshan Bhattarai // Visit http://roshanbh.com.np for this script and more. // This notice MUST stay intact for legal use $country=$_REQUEST['country']; $myFile = "testFilefindcc.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $country); fclose($fh); switch($country) { case "1" : mysql_connect('localhost', '$user', '$password'); mysql_select_db('sok'); $result = mysql_query("select * from QuestList where QuestID = '1'"); $row = mysql_fetch_assoc($result); echo $row['QDescrip']; break; case "2" : echo "GBP"; break; case "3" : echo "NPR"; break; } ?> I'm trying to make my menu dynamic for example I will have a menu with it's submenus and when the user logs on the submenu account will then be shown where it wasn't shown before the user logged on. here is my submenu.controller Code: [Select] <?php class submenus_controller extends controller{ protected $_helpers = array('form', 'html'); protected $_observers = array('seo_uris'); public $model='submenus'; public function ajax_set_submenu($submenu_id){ $submenu=$this->_model->get($submenu_id); $_SESSION['submenu']=$submenu; } } ?> and here is my default page Code: [Select] <!doctype html> <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> <title><?php echo $this->get_title();?></title> <meta name="author" content="team digitalpro"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name = "Description" content = "<?php echo $this->get_description();?>" /> <meta name = "Keywords" content = "<?php echo $this->get_keywords(); ?>" /> <link rel="stylesheet" href="/css/style.css"> <script src="js/libs/modernizr-2.0.6.min.js"></script> </head> <body> <div id="container"> <header> <div class="inhoud"> <div id="logo"><a href="/"><img src="/img/logo.gif" width="306" height="126" border="0" /></a></div> <nav> <div class="menu"> <ul> <?php if (isset($this->_params['menus']) && is_array($this->_params['menus'])){ foreach ($this->_params['menus'] as $menu){ if (!empty($menu['submenus.page_id'])){ $uri=$this->get_uri('/pages/view/'.$menu['submenus.page_id']); }else{ $uri=$this->get_uri("/{$menu['submenus.controller']}/{$menu['submenus.action']}"); } // p($menu); ?> <li><a href="<?php echo $uri ?>" onclick="javascript:return setMenu(<?php echo $menu['id'] ?>);"><?php echo strtoupper($menu['name'])?></a></li> <?php } } ?> </ul> </div> </nav> </div> </header> <div id="hero-pic"> <div id="slogans"><img src="../img/slogans.png" width="277" height="214" /></div> <img src="../img/hero.gif" width="996" height="286" /></div> <main> <div id="left"> <div class="inhoud"> <div id="left-nav"> <ul> <?php if (isset($this->_params['submenus']) && is_array($this->_params['submenus'])){ foreach ($this->_params['submenus'] as $submenu){ if (!empty($submenu['page_id'])){ $uri=$this->get_uri('/pages/view/'.$submenu['page_id']); }else{ $uri=$this->get_uri("/{$submenu['controller']}/{$submenu['action']}"); } ?> <li<?php if ($_SESSION['submenu']['id'] == $submenu['id']){?> class="active"<?php ;} ?>> <a href="<?php echo $uri ?>" onclick="javascript:return setSubMenu(<?php echo $submenu['id'] ?>);"> <?php echo strtoupper($submenu['name'])?> </a> </li> <?php } } ?> </ul> </div> <form method="post" action=""> <input type="text" id="search" /> <input type="submit" name="button" value="GO" class="go" /> </form> <div class="sub-links"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Contact us</a></li> <li><a href="#">Sitemap</a></li> <li><a href="#">Privacy policy</a></li> </ul> </div> </div> </div> <div id="right"> <div class="inhoud"> <?php echo $this->page('view') ?> </div> </div> </main> <footer> <!-- <div class="inhoud"> <ul> <li><a href="#">COMPANY </a></li> <li><a href="#">PRIVATE EQUITY </a></li> <li><a href="#">CONSULTING </a></li> <li><a href="#">INVEST </a></li> <li><a href="#">PARTNERS </a></li> <li><a href="#">NEWS</a></li> </ul> --> <p> </p> <p> </p> </div> </footer> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="/js/libs/jquery-1.6.2.min.js"><\/script>')</script> <script defer src="/js/plugins.js"></script> <script defer src="/js/script.js"></script> <script> window._gaq = [['_setAccount','UAXXXXXXXX1'],['_trackPageview'],['_trackPageLoadTime']]; Modernizr.load({ load: ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js' }); setMenu = function(menu_id){ $.ajax({ url: "/menus/ajax_set_menu/"+menu_id, type: 'POST', dataType: "html", data: { format: 'JSON', }, success: function(data) { } }); } setSubMenu = function(submenu_id){ $.ajax({ url: "/submenus/ajax_set_submenu/"+submenu_id, type: 'POST', dataType: "html", data: { format: 'JSON', }, success: function(data) { } }); } </script> <!--[if lt IE 7 ]> <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script> <script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script> <![endif]--> </body> </html> Hi, I am using php dynamic listing from database. it is working but I wanna integrate to a horizontal css menu how can i integrate my codes to any css horizantal dropdown menu. thans. here my dynamic list. <?php function sinirsiz_kategori($parent) { $sql = mysql_query("SELECT * FROM kategoriler ORDER BY id DESC"); while($row = mysql_fetch_array($sql)) { $diziler[$row['id']] = array('baslik' => $row['baslik'],'parent' => $row['parent']); } $has_childs = false; foreach($diziler as $key => $value) { if ($value['parent'] == $parent) { if ($has_childs === false){ $has_childs = true; echo "\t<ul>"; } echo "<li><a href=\"".$value['baslik'].".php\">".$value['baslik']."</a>"; sinirsiz_kategori($key); echo "</li>\n"; } } if ($has_childs === true) echo "</ul>"; } ?> <?=sinirsiz_kategori(0)?> I want make the following, (I have already a database with three tables (Countries, Timeline and Category)). 1: list of countries (drop down menu 1), Timeline of the countries history (drop down 2) and Category (drop down 3). 2: The selected values of the drop down menus must show take the information from the database. Can any one help me with the coding? Hi guys! I need a php page that is splitted into 2 screens. One will display the navigation menu and the second one is the iframe. As for the navigation menu, I am getting the list of all files in the current directory with readdir(). Then I create an array with all of the items that are folders (is_dir() function) and apply the same script on them. My problem is to correctly display all of the information I gather in an adequate manner. Can anyone help me with that? Also if anyone has ready-to-go scripts, I would highly appreciate that too. Also, once a user choose a file, it should be loaded in the iframe. How do I specify "src" attribute for the iframe, in that case? Thanks! Hi all, my first post here (except my intro post earlier today). I looked for this in the Code Snippet section and didn't see it, and honestly I'm very much a noob at this (for now, at least) so I'm not quite sure what I'd look for anyway. I've got a decent grasp on HTML and CSS and very little PHP. So here's what I need help with: I wrote a simple PHP include so that all my main pages (including the index file) would all use the same file (navtabs.php) for their navigation tabs. But how do I make the code in navtabs.php dynamic for which button should be highlighted on the proper page? Here is the code snippet for my navigation: Code: [Select] <nav> <ul> <li><a href="index.php" class="current">Home</a></li> <li><a href="page-two.php" >Page Two</a></li> <li><a href="page-three.php">Page Three</a></li> <li><a href="page-four.php">Page Four</a></li> <li class="last"><a href="page-five.php">Page Five</a></li> </ul> </nav> Where class="current" is the highlighting attribute. All my pages using the same include of this code show the Home tab highlighted? Hoping someone has a simple fix for me. Thanks! Hello PHPfreaks! I build a website for a company way back when I was still learning basic PHP! Now unfortunaly the webhost has decided to change their security settings, specifically chaning the allow_url_include and allow_fopen_include to off! That however breaks the website that I did, since i am using the following code in calling the various menus around the website: Code: [Select] include(''$site_url'menu.php?menuid=1'); Now I am well aware that this is not the best way to include a menu! ohhh yeah btw, the code for the menu.php file is: Code: [Select] <?php include('config.php'); $menuid = mysql_real_escape_string($_GET['menuid']); $menu_categories = mysql_query("SELECT * FROM " .$db_prefix. "menucategories WHERE id='".$menuid."'"); while($menu_cat = mysql_fetch_array($menu_categories)) { if($menu_cat['display_name'] == "") { $menu = mysql_query("SELECT * FROM " .$db_prefix. "menu WHERE cat = ".$menu_cat['id']." ORDER BY placement ASC"); echo "<ul>"; while($menu_rows = mysql_fetch_array($menu)) { echo "<li><a href='" .$menu_rows['URL']. "' class='".$menu_cat['name']."' >" .$menu_rows['name']. "</a></li>"; } echo "</ul>"; } else { echo "<h4>" .$menu_cat['display_name']. "</h4>"; $menu = mysql_query("SELECT * FROM " .$db_prefix. "menu WHERE cat = ".$menu_cat['id']." ORDER BY placement ASC"); echo "<ul>"; while($menu_rows = mysql_fetch_array($menu)) { echo "<li><a href='" .$menu_rows['URL']. "' class='".$menu_cat['name']."' >" .$menu_rows['name']. "</a></li>"; } echo "</ul>"; } } ?> So i build the website so that you call the various menus around in the website using the menu.php include and setting a variable based on a ID (i.e menu.php?menuid=2) and of course using variables in the URL name you need to define a complete URL in the include, which now with the hosting companies new security policy doesn't work! SO BASICALLY! What I am trying to ask: Is there any alternative to include menu.php?menuid=XX without using the absolute URL? Hi All, I have a snippet of code (below) which I use to create a dynamic menu from a MySQL database for a community website. Fields used in the database a ID parent (what the parent page is) page_order (what is says on the tin) short_title (a short title for the page for the URL) title (the page title - used as the text for the link) content (the content for the page) I have got the dynamic list to display fine, but what I would like to be able to do is give each list item a 'class' tag when it has been selected (and thus is the page being shown). Can anyone suggest how to amend the below code to allow this? Code is: Code: [Select] <!-- ##### START LIST_INFO_PAGES ##### --> <?php include("../config/config.php"); ?> <?php $sql = "SELECT * FROM `PCNET_$filename` WHERE parent = 'council' ORDER BY page_order ASC"; $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); while ($row = mysql_fetch_assoc($sql_result)) { print ''; if ($row["status"]<>'') { echo '<li><a href="../council-indiv.php?id='; echo ($row["id"]).'&short_title='; echo nl2br(stripslashes(utf8_decode($row["short_title"]))).'" title='; echo nl2br(stripslashes(utf8_decode($row["title"]))).'>'; echo nl2br(stripslashes(utf8_decode($row["title"]))).'</a></li>'; }; }; ?> <!-- ##### END LIST_INFO_PAGES ##### --> Help will be welcome! Neil I am building a site using PHP, OOP, and an MVC framework. i am not using laravel, codeignitor, or any other framework, I am building this on my own. I am a newbie to mvc and so I am learning how it all works. I have a dynamic nav menu that populates the categories from the db. The menu/categories will populate and work fine when I view the nav page on its own, but it will not work when it is included in the index view page. What should I do to make the dynamic menu view on all the view pages that i need it to? Below is my code, any guidance would be greatly appreciated. Controller: class Behindthescenes extends Controller { public function __construct() { $this->btsModel = $this->model('mBehindthescene'); } public function index() { $data = [ 'title' => 'Admin Dashboard', ]; $this->view('/behindthescenes/index', $data); } // Get categories for nav menu public function bts_cat_nav() { $catnav = $this->btsModel->getCatsNav(); $data = [ 'catnav' => $catnav, ]; $this->view('/includes/bts_cat_nav', $data); } } Model: class mBehindthescene { private $db; public function __construct() { $this->db = new DBC; } // Get Categories for Admin Navigation public function getCatsNav() { $this->db->query('SELECT * FROM categories ORDER BY cat_name ASC'); $result = $this->db->fetchMultiple(); return $result; } } Index View: require_once APPROOT . '/views/includes/header.php'; require_once APPROOT . '/views/includes/bts_nav.php'; require_once APPROOT . '/views/includes/bts_cat_nav.php'; ?> <div class="container-fluid"> ADMIN DASHBOARD </div> Nav Menu View: <div class="container"> <div class="row"> <div class="cat_nav"> <ul> <?php foreach ($data['catnav'] as $cat): ?> <li class="nav-item"><a href="<?php echo $cat->cat_link; ?> class=" nav-link text-white p-1 mb-1 sidebar-link"><i class="<?php echo $cat->cat_fa; ?> text-light fa-lg mr-3"></i><?php echo $cat->cat_name; ?></a></li> <?php endforeach;?> </ul> </div> </div> </div>
i have created a seating system. based on the number of seats booked that value is passed to a page that dynamicly produces a drop down box for each seat booked so the type of seat price can be assigned. this part works fine. the problem i have is how do i code the recieving page not knowing how many values are going to be passed? this is the drop down menu page Thanks Code: [Select] <form action="payment.php?seatco=<?php echo $s_count; ?>" method="post" name="f1"> <div id="tick_select"> <?php for($i=1; $i<=$s_count; $i++){ $tick= mysql_query("select * from ticket_list"); ?> <select name="tick_com<?php echo $i; ?>" id="tick_com" onChange="" title="Choose A Ticket"> <option value="">Select Ticket type</option> <?php while($result= mysql_fetch_assoc($tick)) { ?> <?php echo '<option value="'.$result[ticket_id].'" name="'.$result[price].'">'.$result[type].'</option>';?> <?php }}?> </select> </div> <INPUT TYPE="submit" VALUE="Select"> </form> hii,everyone... i am new to the forum ..so forgive me if i make some errors in describing my problem i want to create a drop down menu...the values of which i want to retrieve from a table i have created in my database... i have been able to acheive this...but i want a second drop down menu...in which i want the values to get filtered according to the selection of the first drop down menu... i hav a table with the name test...which i am connecting to the first drop down menu i hav created another table with the name testtype...for second menu.. the id of first table is the testid of second... plzz help me with creating the second menu... my code is Code: [Select] <?php $sql_result = "select test_series FROM test"; $result = mysql_query($sql_result); ?> <td>Select Test Series </td> <td> <select name="testseries" id="testseries" )"> <option>Select</option> <?php if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $test = $row['test_series'];?> <option><?php echo $test ?></option> <?php } } else {?> <option>No Names Present</option>"; <?php } ?> </select> </td> </tr> <tr> <?php $testseries = $_POST['testseries']; $query = "select id from test where test_series = '$testseries'"; $resultt = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($resultt); $id = $row['id']; $sql_result = "select test_name FROM testtype where testid = $id"; $result = mysql_query($sql_result); ?> <td>Select Test Name </td> <td> <select name="testtype"> <option>Select</option> <?php if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $test2 = $row['test_name'];?> <option><?php echo $test2 ?></option> <?php } } else {?> <option>No Names Present</option>"; <?php } ?> </select> </td> </tr> IN THIS CODE I AM GETTIN AN ERROR Undefined index: testseries in ..addques.php on line 155 WHICH IS THIS ONE $testseries = $_POST['testseries']; Hey Guys, I'm building a site and I need a drop down menu created dynamicly.... This is the flat html code Code: [Select] <div class="art-nav"> <div class="l"></div> <div class="r"></div> <ul class="art-menu"> <li><a href="URL 1"><span class="l"></span><span class="r"></span><span class="t">TOP LEVEL</span></a> <ul> <li><a href="URL 1">SUB CAT 1</a></li> <li><a href="URL 2">SUB CAT 2</a></li> <li><a href="URL 3">SUB CAT 3</a></li> </ul> </li> <li class="art-menu-li-separator"><span class="art-menu-separator"></span></li> <li><a href="URL 5"><span class="l"></span><span class="r"></span><span class="t">Contact Us</span></a></li> </ul> </div> This is the code that shows a dyamic code, but not in the menu... <?php wpsc_start_category_query(array('category_group'=> get_option('wpsc_default_category'), 'show_thumbnails'=> get_option('show_category_thumbnails'))); ?> <a href="<?php wpsc_print_category_url();?>" class="wpsc_category_link"><?php wpsc_print_category_name();?></a> | <?php wpsc_print_subcategory(); ?> <?php wpsc_end_category_query(); ?> Hi all. I'm working on a project that requires a 3 tier navigation menu that's dynamic and I'm not quite sure where to start with it. The structure of the menu is like so... A unique list of Parent-Modules Tier1: Parent-Module1 Each parent module has a second tier menu that appears upon clicking a parent module. Each parent module has a unique list of tier 2 sub modules Tier 2: Sub-Module1 - Sub-Module2 Each sub module has a third tier menu that appears upon clicking a sub module. Each sub module has a unique list of tier 3 child modules Tier 3: Child-Module1 - Child-Module2 - Child-Module3 A visual: Parent (each parent module has this structure) | |--------Sub Module | |-Child Module 1 | |-Child Module 2 | |-Child module 3 |--------Sub Module | |-Child Module 1 | |-Child Module 2 | |-Child module 3 |--------Sub Module |-Child Module 1 |-Child Module 2 |-Child module 3 Every tier has to be dynamic as the module names/locations are often changed. My thought is to use opendir/readdir in order to build the tiers based on what files exist, but I'm not sure if this is a safe/reliable practice. Any input would be a great help. EDIT: The navigation links would have to have "pretty" names (e.g. Business Processes instead of business_processes). Hi guys, I'm still not having any luck with coming up with an idea of how to make my multi-level drop down menu work with items from a database. I don't necessarily need code, but an idea of how to make it work, so any ideas are welcome. The table: Column Descriptions: id - The unique id label - The text to display link - The link to be used relation - I cannot remember why I wanted that... just disregard it parent - The parent item's id (0 for no parent) sort - A sort number for the item (ascending) active - 0 for false, 1 for true (not implemented yet, will add a WHERE `active` = 1 into the sql later) depth - How many parent items there are Now, here's what it has to do (the class): Grab items from the database (sorted by depth, parent, and sort) Place the children in a child array of the parents (or however it can be sorted) Implode the array and turn it into an html menu with the below structure Menu HTML Structure Code: [Select] <div id="menu"> <ul> <li><h2>Level 1 A</h2> <ul> <li><a href="?r=level2/a">Level 2 A</a> <ul> <li><a href="?r=level3/a">Level 3 A</a></li> <li><a href="?r=level3/b">Level 3 B</a></li> </ul> </li> </ul> </li> <li><a href="?r=level1/b"><h2>Level 1 B</h2></a></li> </ul> </div> And here is the code I have so far, but I can't figure out how to get the children into the parent array, or at least sort it so that I can achieve the above HTML structure. Thank you in advance for your help, and as I said above, I don't necessarily need code, but an idea of how to make it work, so any ideas are welcome. I'm trying to create a dynamic option menu with one alert selected based on the first query to the db. Any help would be greatly appreciated. Code: [Select] //function to get alerts and create select menu with current alerts pre-selected function getALERTS1($id){ require('db.php'); $alert = mysqli_query($conn, "SELECT alert1 FROM visit_data WEHERE patientid = $id AND discharged IS NULL"); $row = mysqli_fetch_array($alert); $selects=null; $query = mysqli_query($conn, "SELECT alertid, name FROM alerts"); while($row1 = mysqli_fetch_array($query)) { $selects .= "<option value=\"" . $row1['alertid'] . "\"> if($row1['alertid']==$row['alert1']) { echo ' selected'; } ".$row1['name']."</option>"; } return $selects; } I have three pages; edit_records.php (list of records, user picks one ready to edit, works fine) update.php (by in large works fine, heres the code for it anyway) Code: [Select] <?php require_once ('./includes/config.inc.php'); require_once (MYSQL); if($id = isset($_GET['prodID'])) { $query = "SELECT * FROM product WHERE prodID='{$_GET['prodID']}'"; $r = mysqli_query($dbc, $query); while ($row = mysqli_fetch_array($r)) { $id = $row['prodID']; $product = $row ['product']; ?> <form action="update_save.php" method="post"> ID: <input type="text" value="<?php echo $id;?>" name="id" disabled="disabled" /> Product: <input type="text" value="<?php echo $product;?>" name="product" /> <br /> <input type="submit" value="submit changes" /> </form> <?php } } and finally update_save.php (this is where the actual updating takes place) Code: [Select] <?php require_once ('./includes/config.inc.php'); require_once (MYSQL); $product = $_POST['product']; $query = "UPDATE product SET product = $product WHERE prodID = '$id'"; $r = mysqli_query($dbc, $query); echo 'Database Updated!!'; ?> however, on line 19 of update save, i get this error; Quote An error occurred in script 'C:\Users\David Morgan\Desktop\WEBSITES\hairz_&_graces\site\admin\update_save.php' on line 9: Undefined variable: id now I am aware i should really create a variable but since i already stored it in update.php, i had hoped it would work but it hasnt. what should i do? help would be much appreciated please I am having a lot of trouble with this code, and I have no clue how to fix it. Right now, I have a GUI for a fictitious car dealership that has 5 populated drop down menus called Make, Model, Year, Color, and Mileage. What I want the code to do is read the selections made by the user with the drop down menus once the user hits the submit button and then filter the tables that I have in a mysql database to meets the choice requirements of the user. The code will bring up the GUI, but once I hit the submit button, I get the following errors Please if anyone can help me that would be fantastic. I really have no clue I added some code last night that updates the "last_activity" field in the "member" table whenever the "body_header.inc.php" script is called, which means that pretty much whenever the User navigates to a new page or submits a form this field is updated. (I use this to kep my "User Online Status" up-to-date.) Everything was working fine until I suddenly started getting a "Cannot modify header" error before bed. Here is ONE sequence causing this error... - I am logged out - I am on http://local.debbie/index.php - I click on the "Log In" link - I am taken to http://local.debbie/members/log_in.php - I log in - I get this error... Quote Warning: Cannot modify header information - headers already sent by (output started at /Users/user1/Documents/DEV/++htdocs/05_Debbie/index.php:22) in /Users/user1/Documents/DEV/++htdocs/05_Debbie/components/body_header.inc.php on line 48 Here is part of my main index.php script... <?php //Build Date: 2012-03-08 // Initialize a session. session_start(); // Access Constants. require_once('config/config.inc.php'); // Set current Script Name. $_SESSION['returnToPage'] = $_SERVER['SCRIPT_NAME']; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- ################## DEBBIE ##################### --> <!-- HTML Metadata --> <title>Double Dee, Inc.</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- Page Stylesheets --> <link type="text/css" rel="stylesheet" href="css/_main.css" /> <link type="text/css" rel="stylesheet" href="css/_layout.css" /> <link type="text/css" rel="stylesheet" href="css/top_menu.css" /> <link type="text/css" rel="stylesheet" href="css/components.css" /> </head> <body> <div id="pageWrapper" class="clearfix"> <div id="pageInner"> <!-- BODY HEADER --> <?php require_once('components/body_header.inc.php'); ?> <!-- LEFT COLUMN --> <div id="pageLeftCol"> Here is a snippet from my body_header.inc.php script... <?php //Build Date: 2012-03-08 // ************************ // Update Last Activity. * // ************************ if ((isset($_SESSION['loggedIn'])) && ($_SESSION['loggedIn'] == TRUE)){ // Initialize Session. // session_start(); // Access Constants. // require_once('../config/config.inc.php'); // Initialize variables. $loggedIn = TRUE; $memberID = (isset($_SESSION['memberID']) ? $_SESSION['memberID'] : ''); // ************************ // Update Member Record. * // ************************ // Connect to the database. require_once(WEB_ROOT . 'private/mysqli_connect.php'); // Build query. $q1 = "UPDATE member SET logged_in=?, last_activity=now() WHERE id=? LIMIT 1"; // Prepare statement. $stmt1 = mysqli_prepare($dbc, $q1); // Bind variables to query. mysqli_stmt_bind_param($stmt1, 'si', $loggedIn, $memberID); // Execute query. mysqli_stmt_execute($stmt1); // Verify Update. if (mysqli_stmt_affected_rows($stmt1)!==1){ // Update Failed. $_SESSION['resultsCode'] = 'MEMBER_UPDATE_FAILED_2126'; // Redirect to Display Outcome. header("Location: " . BASE_URL . "members/results.php"); // End script. exit(); }//End of UPDATE MEMBER RECORD // Close prepared statement. mysqli_stmt_close($stmt1); // Close the connection. mysqli_close($dbc); /* */ }//End of UPDATE LAST ACTIVITY /* // Determine Current Script. $page = basename($_SERVER['REQUEST_URI']); if ($page == '') { $page = "index.php"; } */ // Determine Script Name. $scriptName = $_SERVER['SCRIPT_NAME']; ?> <!-- PAGE HEADER --> <div id="pageHeader"> <!-- COMPANY BRANDING --> <h1 id="companyLogo"> <!-- Display Logo if "Images On" --> <a href="/index.php"> <!-- Image Replacement Technique --> <span></span> </a> <!-- Display Text if "Images Off" --> DoubleDee, Inc: Tips on starting a Small-Business </h1> <!-- WELCOME MESSAGE --> <?php $firstName = (isset($_SESSION['memberFirstName']) ? $_SESSION['memberFirstName'] : ''); I was mindful of extra white space possibly causing the issue, but I don't see where it is?! The "Update Last Activity" code was added to my Header last night and is likely the culprit... Any ideas what is wrong?? Thanks, Debbie hi, Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Sahansevena_ver1\admin\profile\updAdmiInfo.php on line 49 i got this error. here is the coding Code: [Select] <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $dbuser="root"; $dbpswd="****"; $dbserver="localhost"; $nwuser=$_POST['username']; $c_pw=$_POST['cur_password']; $n_pw=$_POST['conf_password']; //$user=$userName; //$pass=$password; // $dbname="sahansevena"; if($_SERVER['REQUEST_METHOD']=='POST'){ //get username and password from admin login.php $con=mysql_connect($dbserver,$dbuser,$dbpswd); if(!$con){ die('coudnt connect db connection prob'.mysql_error()); }else{ if($c_pw==$n_pw){ $uname=mysql_real_escape_string($username); $pword=mysql_real_escape_string($n_pw); // setDatabase($dbname, $con) ; mysql_select_db($dbname, $con); // $result="update admin set username='$uname',password='$pword'" where limit 0; $result="update admin set username='$uname' , password='$pword', last_logged_date =CURDATE(), last_log_time=CURTIME() where username='$uname' limit 0"; //Checked to see if any rows were returned from the database // If rows were returned, set a session variable to 1 $result=mysql_query($result); if ($result) { $numRow=mysql_numrows($result); if($numRow>0){ //session_start(); //SESSION['admin']="menuka"; echo "data was suaccesfully updated"; /// header ("Location:config/menu.php"); //mysql_close($con); }else{ //session_start(); echo " problem in updating "; //$_SESSION['login'] = ""; //header ("Location:login.php"); } } else { trigger_error(mysql_error(), E_USER_ERROR); } } } }else{ echo 'error message not post methode'; include(login.php); } ?> please check my code and help me to figur out the error thanks in advance, menukadevinda |