CodeIgniter Forums
Dynamic Menu - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Dynamic Menu (/showthread.php?tid=59870)



Dynamic Menu - El Forum - 12-03-2013

[eluser]cerberus478[/eluser]
Hi I'm using codeigniter 2.1.4

I'm trying to create a menu where I can select a page that goes with it.

For example:

I go to my create menu page and in that page I enter the menu title and I will have a drop down box that gives me all the page titles that I have. When I click save it has to automatically save that information in the database.

In my menus table I have
Code:
CREATE TABLE `menus` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(250) NOT NULL,
  `page_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `page_id` (`page_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `menus`
--
ALTER TABLE `menus`
  ADD CONSTRAINT `menus_ibfk_1` FOREIGN KEY (`page_id`) REFERENCES `pages` (`id`) ON UPDATE CASCADE;

and my pages table
Code:
CREATE TABLE `pages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(240) NOT NULL,
  `slug` varchar(250) NOT NULL,
  `content` varchar(240) NOT NULL,
  `meta_title` varchar(240) NOT NULL,
  `meta_description` varchar(240) NOT NULL,
  `keywords` varchar(240) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;

--
-- Dumping data for table `pages`
--

INSERT INTO `pages` (`id`, `title`, `slug`, `content`, `meta_title`, `meta_description`, `keywords`) VALUES
(24, 'Home Page', 'Home-Page', 'Home page<br>', 'home page', 'home page', 'home page');

Can some one tell me how to do this or can give me a tutorial that will show me how to do this.