Jump to content

create a new page on submit from database


tibewww

Recommended Posts

Hi everybody,
 
I'm starting with PHP and Mysql, so it's getting diffictul at this poinf for me and i'm looking for a bit of help =).
 
I've created a chained menu using php and a database, following this tutorial:

http://www.yourinspirationweb.com/en/how-to-create-chained-select-with-php-and-jquery/
 
The frist table content a list of categories like :
 
CREATE TABLE IF NOT EXISTS `chainmenu_categories` (
  `id_cat` int(4) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(40) NOT NULL,
  PRIMARY KEY (`id_cat`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
 
My second table, the type, like :
 

CREATE TABLE IF NOT EXISTS `type` (
  `id_type` int(4) unsigned NOT NULL AUTO_INCREMENT,
  `id_cat` int(4) unsigned NOT NULL,
  `name` varchar(40) NOT NULL,
  `destination` varchar(40) NOT NULL,
  PRIMARY KEY (`id_type`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
 
I managed, once cliking on submit, to redirect to an other page by that in my select.php:

 

var result = $("select#type option:selected").html();
$("#select_form").submit(function( event ) {
  var the_url = $("#type").val();
  window.location = the_url;
  event.preventDefault();
});
 
and adding this on my select.class.php
 
public function ShowCategory()
        {
            $sql = "SELECT * FROM chainmenu_categories";
            $res = mysql_query($sql,$this->conn);
            $category = '<option value="0">choose...</option>';
            while($row = mysql_fetch_array($res))
            {
                $category .= '<option value="' . $row['id_cat'] . $row['destination']. '">' . $row['name'] . '</option>';
            }
            return $category;
        }
 
So now it redirect each time to a different  page depending of the option choose from the menu, like: http://mydomain.com//3 or http://mydomain.com//4 or http://mydomain.com//5 etc etc
 
But as the page doesnt exist, it redirect each time to a dead link,
 
Is anybody can give me a help to create these pages from the chained menu ( or have some highlite) ? and If possiblles, some pointer to create the admin interface to allow an admin to add the pages / chained menu ?
 
I've been trying to start with something which look like:
 
<?php require('db_config.php'); 
 
 
 
$stmt = $db->prepare('SELECT id_type, name FROM type WHERE id_cat=$_POST[id]');
$stmt->execute(array(':id_cat' => $_GET['name']));
$row = $stmt->fetch();
 
but dont know if i'm in the good way at all, I' just so confused !

Thank you in advance for your recommandatiosn guys !!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.