maybe i didnt see whats wrong? :S
these are my sql tables...
Code: Select all
CREATE TABLE `user` (
`user_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`first_name` VARCHAR( 40 ) NOT NULL ,
`last_name` VARCHAR( 40 ) NOT NULL ,
`email` VARCHAR( 128 ) NOT NULL ,
`country` VARCHAR( 128 ) NOT NULL ,
`university_dep` VARCHAR( 250 ) NOT NULL ,
`university` VARCHAR( 250 ) NOT NULL ,
`phone` VARCHAR( 30 ) NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE TABLE `editor` (
`editor_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`editor` TEXT
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE TABLE `user_editor` (
`user_id` INT NOT NULL ,
`editor_id` SMALLINT NOT NULL ,
PRIMARY KEY ( `user_id` , `editor_id` )
) ENGINE = MYISAM ;
my html & php form...
Code: Select all
<form action="_add.php" method="post">
<table width="900" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Name</td>
<td><input name="name" type="text" id="name" size="30"></td>
</tr>
<input type="checkbox" name="committee[]" value="ijh" /> Inter <br>
<input type="checkbox" name="committee[]" value="pwt" /> Proceed <br>
<input type="checkbox" name="committee[]" value="ijc" /> Int <br>
<td><input name="add" type="submit" id="add" value="Add New User"></td>
</tr>
</table>
</form>
_add.php
Code: Select all
<?php
if(isset($_POST['add']) ) {
include("dbconfig.php");
$name = $_POST['name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$country = $_POST['country'];
$university = $_POST['university'];
$university_dep = $_POST['university_dep'];
$phone=$_POST['phone'];
foreach ( $_POST['committee'] AS $committee ) {
$query="INSERT INTO editor(editor) VALUES ('$committee')";
$result = mysql_query($query) or die ("query not made");
}
$result= mysql_query("INSERT INTO user (first_name, last_name, email, country,university_dep,university,phone) VALUES ( ' $name ' , ' $surname ' , ' $email ' , ' $country ' , ' $university ' , ' $university_dep ' , ' $phone ') ");
}
else
{
include("index.html");
}
?>
and this is the output but still working incorrectly...
but i just want to make , user will select the checkbox and all of the checked values will be inside of the editor table -> editor field..
http://img264.imageshack.us/my.php?imag ... gdfpw9.jpg
some of the user has 4 value, some of them 2 , some of them 1 and (Array) ...
my mind is realy mixed