Populating drop down list with mysql data and add to db
Posted: Fri Jun 20, 2008 5:25 am
Hello, I am trying to populate some drop down lists with mysql data and add them to the database through a form.
I have managed to populate the drop down list using the following code.
This is the entire code of the process page.
<?php
function insertJob() {
$job_title = htmlspecialchars(trim($_POST['job_title']), ENT_QUOTES);
$job_description = str_replace(array("\r\n", "\n", "\r"), "<br />", htmlspecialchars(trim($_POST['job_description']), ENT_QUOTES));
$job_function = implode(" ", $_POST['job_function']);
$job_language = implode(" ", $_POST['job_language']);
$job_location = implode(" ", $_POST['job_location']);
$job_industry = implode(" ", $_POST['job_industry']);
$job_contract = implode(" ", $_POST['job_contract']);
$job_experience = implode(" ", $_POST['job_experience']);
$job_education = implode(" ", $_POST['job_education']);
$job_offer = str_replace(array("\r\n", "\n", "\r"), "<br />", htmlspecialchars(trim($_POST['job_offer']), ENT_QUOTES));
$job_reference = htmlspecialchars(trim($_POST['job_reference']), ENT_QUOTES);
$job_address = str_replace(array("\r\n", "\n", "\r"), "<br />", htmlspecialchars(trim($_POST['job_address']), ENT_QUOTES));
$job_happly = implode(" ", $_POST['job_happly']);
$job_payment = implode(" ", $_POST['job_payment']);
$pk = decryptUser();
$date = date('Y-m-d');
queryDatabase("INSERT INTO job (job_title, job_description, job_inserted, in_industry, in_location, in_user, in_function, in_contract, in_experience, in_education, job_offer, job_reference, job_address, in_happly, in_payment, in_language)
VALUES ('$job_title', '$job_description', '$date', '$job_function', '$job_location', '$job_industry', '$job_contract', '$job_experience', '$job_education', '$job_offer', '$job_reference', '$job_address', '$job_happly', '$job_payment', '$job_language', $pk)");
)
?>
Now when i input the valus and submit, i am getting the following error..
Parse error: syntax error, unexpected ')' in C:\AppServ\www\sitename\library\process.php on line 47
Can anyone help me out please....
Edit/Delete Message
I have managed to populate the drop down list using the following code.
Code: Select all
<strong>Function:</strong><br />
<?php
$query="SELECT name FROM job_function";
$result = mysql_query ($query);
echo "<select name='in_function'>name</option>";
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[id]>$nt[name]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>
<br />
<br />
<?php
function insertJob() {
$job_title = htmlspecialchars(trim($_POST['job_title']), ENT_QUOTES);
$job_description = str_replace(array("\r\n", "\n", "\r"), "<br />", htmlspecialchars(trim($_POST['job_description']), ENT_QUOTES));
$job_function = implode(" ", $_POST['job_function']);
$job_language = implode(" ", $_POST['job_language']);
$job_location = implode(" ", $_POST['job_location']);
$job_industry = implode(" ", $_POST['job_industry']);
$job_contract = implode(" ", $_POST['job_contract']);
$job_experience = implode(" ", $_POST['job_experience']);
$job_education = implode(" ", $_POST['job_education']);
$job_offer = str_replace(array("\r\n", "\n", "\r"), "<br />", htmlspecialchars(trim($_POST['job_offer']), ENT_QUOTES));
$job_reference = htmlspecialchars(trim($_POST['job_reference']), ENT_QUOTES);
$job_address = str_replace(array("\r\n", "\n", "\r"), "<br />", htmlspecialchars(trim($_POST['job_address']), ENT_QUOTES));
$job_happly = implode(" ", $_POST['job_happly']);
$job_payment = implode(" ", $_POST['job_payment']);
$pk = decryptUser();
$date = date('Y-m-d');
queryDatabase("INSERT INTO job (job_title, job_description, job_inserted, in_industry, in_location, in_user, in_function, in_contract, in_experience, in_education, job_offer, job_reference, job_address, in_happly, in_payment, in_language)
VALUES ('$job_title', '$job_description', '$date', '$job_function', '$job_location', '$job_industry', '$job_contract', '$job_experience', '$job_education', '$job_offer', '$job_reference', '$job_address', '$job_happly', '$job_payment', '$job_language', $pk)");
)
?>
Now when i input the valus and submit, i am getting the following error..
Parse error: syntax error, unexpected ')' in C:\AppServ\www\sitename\library\process.php on line 47
Can anyone help me out please....
Edit/Delete Message