I'm posting this again, because I still haven'e been able to modify my existing code to allow for multiple inserts. I've simplified the page down to just one listbox and have included most of the code here. I know most of you don't like generated code, but I have to work with it for now due to time contrainsts. If someone could re-write what I have here just enough to allow multiple selections to be inserted into seperate rows, I'd really appreciate it. I think the listbox has to be an array that will have to be looped through for the insert, but I don't know how to do it. Thanks in advance. It's the "category" that I want to allow multiple selections for. Here's the code:
<?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"] == "insert")) {
$insertSQL = sprintf("INSERT INTO job_categories (job_id, category_id) VALUES (1, %s)",
GetSQLValueString($HTTP_POST_VARS['category'], "int"));
mysql_select_db($database_connJobFerret, $connJobFerret);
$Result1 = mysql_query($insertSQL, $connJobFerret) or die(mysql_error());
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<form action="<?php echo $editFormAction; ?>" method="POST" name="insert" id="insert">
<select name="category" size="6" multiple="multiple">
<option value="1">Accounting/Auditing</option>
....(etc)
<option value="81">Waste Management</option>
</select>
<input type="submit" name="Submit" value="Submit">
<input type="hidden" name="MM_insert" value="insert">
</form></td>
</tr>
</table>
</body>
</html>[/code]