dreamz boy Posted March 3, 2013 Share Posted March 3, 2013 i am new in programming and creating my first dynamic website. and problem i am facing is that when i parse the query in the php for menu of my website it gives only one menu link and hides the other pages created in the database.if i create a new page in mysql the parse code hides the previous page link in the menu and shows the newly created page link. i want to make that every page created in database link is shown in menu. and also guide me what changes i have to do if i want to make menu with sub menu option.thankshere are the msql code CREATE TABLE `pages` ( `id` int(11) NOT NULL AUTO_INCREMENT, `pagetitle` varchar(255) COLLATE latin1_general_ci NOT NULL, `linklabel` varchar(255) COLLATE latin1_general_ci NOT NULL, `pagebody` text COLLATE latin1_general_ci NOT NULL, `pageorder` int(11) NOT NULL, `showing` enum('0','1') COLLATE latin1_general_ci NOT NULL DEFAULT '1', `keywords` varchar(255) COLLATE latin1_general_ci NOT NULL, `description` varchar(255) COLLATE latin1_general_ci NOT NULL, `lastmodified` date NOT NULL, `extra` varchar(255) COLLATE latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ; for parsing$sqlCommand = "SELECT id, linklabel FROM pages WHERE showing='1' ORDER BY id ASC"; $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); $menuDisplay = ''; while ($row = mysqli_fetch_array($query)) { $pid = $row["id"]; $linklabel = $row["linklabel"]; $menuDisplay = '<li><a href="index.php?pid=' . $pid . '">' . $linklabel . '</a></li>'; and to display menu php code i am using is<?php echo $menuDisplay; ?> Quote Link to comment Share on other sites More sharing options...
fenway Posted March 3, 2013 Share Posted March 3, 2013 I'm not sure where your question lies -- in the DB queries,, the PHP syntax for loops, or the HTML rendering? Quote Link to comment Share on other sites More sharing options...
Solution dreamz boy Posted March 3, 2013 Author Solution Share Posted March 3, 2013 i have solved the issue the problem was in php syntax changed $menuDisplay = to $menuDisplay .= and its work for me. i have second issue related to above table(db queries) that i want to create title, keywords and descriptions dynamic for pages created in database. for title i used this sytax $sqlCommand = "SELECT pagetitle FROM pages WHERE showing='1' LIMIT 1"; $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); while ($row = mysqli_fetch_array($query)) { $title = $row["pagetitle"]; } mysqli_free_result($query); but this is not working for me it only insert the first page title to all pages. please guide or tell me what will be php syntax to get title, keywords, and description dynamically. thanks in advanced Quote Link to comment Share on other sites More sharing options...
dreamz boy Posted March 4, 2013 Author Share Posted March 4, 2013 problem resolved i used pageid to do title dynamic and it work for me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.