Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to put the value of the id of a table into another table
    primarykey
    data
    text
    <p>i have two table in a database one is register table another is type table. I'm trying to create a form that will include a drop down menu derived from the 'type' table and the values of the form will be inserted in the 'register' table. When a option is selected the id of the type will be inserted in to foreign id field of the 'register' table where the values of the form is actually posted. I'm really stuck with this problem. please help.</p> <p>my form looks like this</p> <p>enter code here</p> <pre><code>&lt;form action="form1.php" method="post"&gt; Name: &lt;input type="text" name="name" /&gt;&lt;br/&gt;&lt;br/&gt; Username: &lt;input type="text" name="username" /&gt;&lt;br/&gt;&lt;br/&gt; Password: &lt;input type="password" name="password" /&gt;&lt;br/&gt;&lt;br/&gt; Email: &lt;input type="text" name="email" /&gt;&lt;br/&gt;&lt;br/&gt; You are: &lt;select name="type" size="3 multiple"&gt; &lt;option value="1" selected="selected"&gt;Super admin&lt;/option&gt; &lt;option value="2"&gt;Admin&lt;/option&gt; &lt;option value="3"&gt;User&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" name="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre> <p>and the tables</p> <hr> <ul> <li>Table <code>project</code>.<code>type</code></li> </ul> <hr> <pre><code>CREATE TABLE IF NOT EXISTS `project`.`type` ( `id` INT NOT NULL AUTO_INCREMENT , `type` VARCHAR(45) NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB; </code></pre> <hr> <ul> <li>Table <code>project</code>.<code>register</code></li> </ul> <hr> <pre><code>CREATE TABLE IF NOT EXISTS `project`.`register` ( `id` INT NOT NULL , `name` VARCHAR(45) NULL , `username` VARCHAR(45) NULL , `password` VARCHAR(45) NULL , `email` VARCHAR(45) NULL , `phone` VARCHAR(45) NULL , `type_id` INT NOT NULL , PRIMARY KEY (`id`) , UNIQUE INDEX `id_UNIQUE` (`id` ASC) , INDEX `fk_register_type1` (`type_id` ASC) , CONSTRAINT `fk_register_type1` FOREIGN KEY (`type_id` ) REFERENCES `project`.`type` (`id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload