seanstuart Posted January 7, 2008 Share Posted January 7, 2008 I am working with a CMS Restaurant system, I would like to allow owners to have an option to select currency type e.g [ $,£ and €, ] what would be the easyest way to achieve this without having to edit lots of files? regards Sean Quote Link to comment https://forums.phpfreaks.com/topic/84873-create-dropdown-select-from-database/ Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 If you already have the DB setup, and it has a table for currency, then just read each entry and put it in a option tag. Quote Link to comment https://forums.phpfreaks.com/topic/84873-create-dropdown-select-from-database/#findComment-432673 Share on other sites More sharing options...
seanstuart Posted January 7, 2008 Author Share Posted January 7, 2008 this is how the origonal script looks at add_menu_item.php... and edit_menu_item.php will i have to these and how would i call it? <?php require_once("access.php"); require_once(LIB_PATH."Restaurant.php"); require_once(LIB_PATH."Menu.php"); require_once(LIB_PATH."MenuSection.php"); require_once(LIB_PATH."MenuItem.php"); $restaurant_id = Sanitize::data($_GET['restaurant_id'], "integer"); $menu_id = Sanitize::data($_GET['menu_id'], "integer"); $section_id = Sanitize::data($_GET['section_id'], "integer"); if($restaurant_id == 0){ $error_message = "You must select a restaurant, prior to be able to add a menu item!"; }elseif($menu_id == 0){ $error_message = "You must select a menu, prior to be able to add a menu item!"; }else{ $restaurant_obj = new Restaurant($restaurant_id); if($restaurant_obj->user_id == $_SESSION['logged_user_id']){ $menu_obj = new Menu($restaurant_id); //get the menu sections $menu_sections = MenuSection::allMenuSections($menu_obj->menu_id); if(multiArraySearchValue($menu_sections, 'section_id', $section_id) >= 0){ /** * Determinate does the form was submited. */ if($_SERVER['REQUEST_METHOD'] == "POST"){ /** * Intance the restaurant object */ $mi_obj = new MenuItem(); /** * Sanitize the posted values. */ $item_name = Sanitize::data($_POST['item_name'], "string"); $item_description = Sanitize::data($_POST['item_description'], "string"); $item_price = Sanitize::data($_POST['item_price'], "float"); $item_order = Sanitize::data($_POST['item_order'], "string"); $section_id = Sanitize::data($_POST['section_id'], "integer"); /** * Set the object properties. */ $mi_obj->setMember("item_name", $item_name); $mi_obj->setMember("item_description", $item_description); $mi_obj->setMember("item_price", $item_price); $mi_obj->setMember("item_order", $item_order); $mi_obj->setMember("section_id", $section_id); /** * Try to add the new menu section to the database. */ if($mi_obj->add($error_message)){ /** * Redirect the user to the "thank you" page. */ header("location: restaurant.php?id=$restaurant_id"); exit; } } }else{ //this menu section do not belongs to the current logged user $error_message = "You must create at least one menu section, prior to be able to add a menu item!"; } }else{ //this menu restaurant do not belongs to the current logged user header("location: index.php"); exit; } if(! $item_status) $item_status = 1; /** * Get the menu sections array. */ $menu_sections = MenuSection::allMenuSections($menu_id); $select_section = get_select_box_db('0', $section_id, "section_id", $menu_sections, 'section_name', 'section_id', '---select---', 'base', ''); } $form_title = "Add a new menu item"; $website_title = "Add menu item - ".$_SESSION['settings']['site_title']; $website_description = $_SESSION['settings']['site_description']; $site_keywords = $_SESSION['settings']['site_keywords']; require_once(WEB_TEMPLATES."HeaderTemplate.php"); require_once(WEB_TEMPLATES."MenuItemManageTemplate.php"); require_once(WEB_TEMPLATES."FooterTemplate.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/84873-create-dropdown-select-from-database/#findComment-432676 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.