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
https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/
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
https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/#findComment-611122
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
https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/#findComment-611133
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.