Jump to content

Urgent - Comments Pls


plodos

Recommended Posts

I havent any exprience....could you check the code...

I used two insert, 3 different table and join

 

Its is working but, thats better to make a good code;)

 

<?php
include("dbconfig.php");

$title=$_POST['title'];
$name = $_POST['name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$country = $_POST['country'];
$university = $_POST['university'];
$university_dept = $_POST['university_dept'];
$phone=$_POST['phone']; 
$fax = $_POST['fax'];
$committee = $_POST['committee'];
$link = $_POST['link'];
$research = $_POST['research'];
$address = $_POST['address'];
$date = date("Y-m-d H:m:s");

$total_id = mysql_query("SELECT * FROM PERSON");
$num_rows = mysql_num_rows($total_id);
$num_rows++;

$sql = "select committee_id from committee where name='$committee'";
$id = mysql_query($sql);
$result = mysql_fetch_assoc($id);
foreach ($result as $v) 
{
   $k=$v;
}
$count_commit = $k; // which committe selected


$add_person= mysql_query(" INSERT INTO person (title,fname,lname,email,country,university,university_dept,phone,fax,research_field,address,paper_link,date) VALUES ('$title','$name','$surname','$email','$country','$university','$university_dept','$phone','$fax','$research','$address','$link','$date')  "); 

$add_join_person_committee = mysql_query(" INSERT INTO join_person_committee (person_id,committee_id) values ('$num_rows','$count_commit')  ");

if($add_person && $add_join_person_committee)
{

	header('Location: http://localhost/committee/organization');

}
else
{
echo "Error";
}
?>

 

dbase.sql

CREATE TABLE `person` (
`person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR(20) NOT NULL,
`fname` VARCHAR( 40 ) NOT NULL ,
`lname` VARCHAR( 40 ) NOT NULL ,
`email` VARCHAR( 128 ) NOT NULL ,
`country` VARCHAR( 128 ) NOT NULL ,
`university` TEXT NOT NULL,
`university_dept` TEXT NOT NULL,
`phone` VARCHAR(40) NOT NULL,
`fax` VARCHAR(40) NOT NULL,
`research_field` TEXT NOT NULL,
`address` TEXT NOT NULL,
`paper_link` TEXT NOT NULL,
`date` DATETIME
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `committee` (
`committee_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` TEXT NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `join_person_committee` (
`person_id` INT NOT NULL ,
`committee_id` SMALLINT NOT NULL ,
PRIMARY KEY ( `person_id` , `committee_id` )
) ENGINE = MYISAM ;

Link to comment
Share on other sites

I think he urgently want's us to optimize his code?

 

Freelance section.

 

And for future reference, I refuse to help people who mark their issues as 'Urgent.' What makes your issue more important than everyone else's? This is a forum of volunteers, and we'll help you at our own pace.

Link to comment
Share on other sites

I think he urgently want's us to optimize his code?

 

Freelance section.

 

And for future reference, I refuse to help people who mark their issues as 'Urgent.' What makes your issue more important than everyone else's? This is a forum of volunteers, and we'll help you at our own pace.

 

sorry

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.