I've asked this question before, but it never got resolved. I've posted the complete php code, but be warned as it's generated by Dreamweaver. Basically it works, but I want the user to be ablo to select multiple categories from a listbox and have them each put into a table in seperate rows with the job_id. The way it's written now, only one category will get inserted. I know I have to loop through the choices somehow but I don't know how. I want to learn php more in the future, but for now I want to work with the generated code. Can someone tell me as simply as possible what I would have to do to get this to include each of the selections. Thanks.
<?php require_once('Connections/connJobFerret.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "job_posting")) {
$insertSQL = sprintf("INSERT INTO jobs (job_id, employer_id, job_title, job_description, qualifications, contact_info, other_info, province, city) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['job_id'], "int"),
GetSQLValueString($HTTP_POST_VARS['employer_id'], "int"),
GetSQLValueString($HTTP_POST_VARS['job_title'], "text"),
GetSQLValueString($HTTP_POST_VARS['job_description'], "text"),
GetSQLValueString($HTTP_POST_VARS['qualifications'], "text"),
GetSQLValueString($HTTP_POST_VARS['contact_info'], "text"),
GetSQLValueString($HTTP_POST_VARS['other_info'], "text"),
GetSQLValueString($HTTP_POST_VARS['province'], "text"),
GetSQLValueString($HTTP_POST_VARS['city'], "text"));
mysql_select_db($database_connJobFerret, $connJobFerret);
$Result1 = mysql_query($insertSQL, $connJobFerret) or die(mysql_error());
$insertGoTo = "invoicing.htm";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "job_posting")) {
$insertSQL = sprintf("INSERT INTO job_categories (category_id, job_id) VALUES (%s, LAST_INSERT_ID())",
GetSQLValueString($HTTP_POST_VARS['lstCareers'], "int"));
mysql_select_db($database_connJobFerret, $connJobFerret);
$Result1 = mysql_query($insertSQL, $connJobFerret) or die(mysql_error());
$insertGoTo = "job_postings.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$empid_rsEmployers = "1";
if (isset($HTTP_GET_VARS['employer_id'])) {
$empid_rsEmployers = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['employer_id'] : addslashes($HTTP_GET_VARS['employer_id']);
}
mysql_select_db($database_connJobFerret, $connJobFerret);
$query_rsEmployers = sprintf("SELECT * FROM employers WHERE employer_id = %s", $empid_rsEmployers);
$rsEmployers = mysql_query($query_rsEmployers, $connJobFerret) or die(mysql_error());
$row_rsEmployers = mysql_fetch_assoc($rsEmployers);
$totalRows_rsEmployers = mysql_num_rows($rsEmployers);
mysql_select_db($database_connJobFerret, $connJobFerret);
$query_rsJobs = "SELECT * FROM jobs";
$rsJobs = mysql_query($query_rsJobs, $connJobFerret) or die(mysql_error());
$row_rsJobs = mysql_fetch_assoc($rsJobs);
$totalRows_rsJobs = mysql_num_rows($rsJobs);
?>