Solved

INSERT MULTIPLE RECORDS IN MYSQL DB USING SELECT FIELD (warning - dreamweaver code!)

Posted on 2008-06-10
8
997 Views
Last Modified: 2013-12-13
trying to insert multiple records (spec_id)s. using multiple select with the code below. here's the form part:

<form method="POST" name="Form1" class="form" action="<?php echo $editFormAction; ?>"  enctype="multipart/form-data" onSubmit="FX_processPop();">
      <fieldset>

                  <legend>SPECIALTIES</legend>
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
 
<tr>
  <td valign="top" align="right" width="200">
                    <dt class="formRequired">
                        
                    <strong>Specialty:<br>
</strong>(hold down the Ctrl key to select more than one) </dt>                  </td>
  <td valign="top" align="left" width="300">
<select name="spec_id" multiple id="spec_id">
<?php
do {  
?>
<option value="<?php echo $row_rsSpecialties['spec_id']?>"><?php echo $row_rsSpecialties['specialty']?></option>
<?php
} while ($row_rsSpecialties = mysql_fetch_assoc($rsSpecialties));
  $rows = mysql_num_rows($rsSpecialties);
  if($rows > 0) {
      mysql_data_seek($rsSpecialties, 0);
        $row_rsSpecialties = mysql_fetch_assoc($rsSpecialties);
  }
?>
</select>
<input name="doc_id" type="hidden" value="<?php echo $row_rsMainIDDesc['main_id']; ?>">
</td>
  </tr>
</table>
</fieldset>

      <p>
  <input type="submit" name="Submit" value="Add Physician Photo &gt;&gt;">
  &nbsp;
  <input type="reset" name="Submit2" value="Start Over">

  <input type="hidden" name="MM_insert" value="Form1">
</p>
<p align="center">&nbsp;</p>
      
              
      <input type="hidden" name="MM_insert" value="Form1">
</form>
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "Form1")) {
  $insertSQL = sprintf("INSERT INTO docspec (doc_id, spec_id) VALUES (%s, %s)",
                       GetSQLValueString($_POST['doc_id'], "int"),
                       GetSQLValueString($_POST['spec_id'], "int"));
 
  mysql_select_db($database_SCOI, $SCOI);
  $Result1 = mysql_query($insertSQL, $SCOI) or die(mysql_error());
 
  $insertGoTo = "add3.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

Open in new window

0
Comment
Question by:phillystyle123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 4

Accepted Solution

by:
afzz earned 500 total points
ID: 21757655
change your code to the following and try
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "Form1")) {
foreach ($_POST['spec_id'] as $val){
  $insertSQL = sprintf("INSERT INTO docspec (doc_id, spec_id) VALUES (%s, %s)",
                       GetSQLValueString($_POST['doc_id'], "int"),
                       GetSQLValueString($val, "int"));
 }
  mysql_select_db($database_SCOI, $SCOI);
  $Result1 = mysql_query($insertSQL, $SCOI) or die(mysql_error());
 
  $insertGoTo = "add3.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

Open in new window

0
 
LVL 4

Expert Comment

by:afzz
ID: 21757667
also your html should be changed as follows
<select name="spec_id" multiple="multiple">

Open in new window

0
 
LVL 4

Assisted Solution

by:afzz
afzz earned 500 total points
ID: 21757862
update, your html code should be. I missed that earlier
<select name="spec_id[]" multiple="multiple">

Open in new window

0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

Author Comment

by:phillystyle123
ID: 21783208
i'm still only inserting one record at a time into the db

is:

foreach ($_POST['spec_id'] as $val){

the only thing needed to add to the php?  (i also updated the form field)
<?php require_once('../../Connections/SCOI.php'); ?>
<?php
 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "Form1")) {
foreach ($_POST['spec_id'] as $val){
  $insertSQL = sprintf("INSERT INTO docspec (doc_id, spec_id) VALUES (%s, %s)",
                       GetSQLValueString($_POST['doc_id'], "int"),
                       GetSQLValueString($val, "int"));
 }
  mysql_select_db($database_SCOI, $SCOI);
  $Result1 = mysql_query($insertSQL, $SCOI) or die(mysql_error());
 
  $insertGoTo = "add3.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
 
 
 
mysql_select_db($database_SCOI, $SCOI);
$query_rsSpecialties = "SELECT specialty, spec_id FROM specialties ORDER BY specialty ASC";
$rsSpecialties = mysql_query($query_rsSpecialties, $SCOI) or die(mysql_error());
$row_rsSpecialties = mysql_fetch_assoc($rsSpecialties);
$totalRows_rsSpecialties = mysql_num_rows($rsSpecialties);
 
mysql_select_db($database_SCOI, $SCOI);
$query_rsLocations = "SELECT location, loc_id FROM locations ORDER BY location ASC";
$rsLocations = mysql_query($query_rsLocations, $SCOI) or die(mysql_error());
$row_rsLocations = mysql_fetch_assoc($rsLocations);
$totalRows_rsLocations = mysql_num_rows($rsLocations);
 
mysql_select_db($database_SCOI, $SCOI);
$query_rsSectionTitle = "SELECT category FROM admin_categories WHERE section_id = '1' AND cat_id = '1'";
$rsSectionTitle = mysql_query($query_rsSectionTitle, $SCOI) or die(mysql_error());
$row_rsSectionTitle = mysql_fetch_assoc($rsSectionTitle);
$totalRows_rsSectionTitle = mysql_num_rows($rsSectionTitle);
 
mysql_select_db($database_SCOI, $SCOI);
$query_rsMainIDDesc = "SELECT main_id, lastname, firstname, mi FROM doctors ORDER BY main_id DESC";
$rsMainIDDesc = mysql_query($query_rsMainIDDesc, $SCOI) or die(mysql_error());
$row_rsMainIDDesc = mysql_fetch_assoc($rsMainIDDesc);
$totalRows_rsMainIDDesc = mysql_num_rows($rsMainIDDesc);
?><html>
<head>
<title>The Physicians of SCOI  - The Southern California Orthopedic Institute</title>
 
<meta name="keywords" content="orthopedic surgeon, orthopedic surgery, los angeles, southern california, arthroscopy, physical therapy, sports medicine, occupational therapy, knee pain, knee injuries, neurology, knee surgery, spine, knee, physical therapist, knee injury, orthopedics, rehabilitation, neurosurgery, vocational rehabilitation, cervical spine, human spine, spine anatomy, lumbar spine, spine surgery, knee arthroscopy, acl rehabilitation, knee rehabilitation, orthopedic medicine, shoulder arthroscopy, orthopedic answers, arthritis, rheumatoid arthritis, knee surgery, shoulder pain, frozen shoulder, swollen ankles, acl, shoulder injuries, joint pain, back surgery, sprained ankle, ankle injuries, shoulder, shoulder surgery, arthritis treatment, degenerative joint disease, acl surgery, ankle sprain, orthopaedics, acl injuries, acl reconstruction, orthopaedic, orthopaedic surgery, orthopaedic surgeons, anatomy, knee, shoulder, ankle, anterior cruciate ligament, ACL, rotator cuff, arthritis, spine, carpal tunnel, scoliosis, hip replacement, knee replacement, joint replacement, osteoporosis">
 
<meta name="description" content="The Southern California Orthopedic Institute (SCOI) - serving the Los Angeles and San Fernando Valley California in orthopedic surgery, sports medicine, knee and shoulder surgery, joint replacement, MRI, and physical rehabilitation.">
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="../../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="../../style.css" rel="stylesheet" type="text/css">
 
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style></head>
<body bgcolor="#bdbdbd" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../../images/about-over.gif','../../images/services-over.gif','../../images/physicians-over.gif','../../images/locats-over.gif','../../images/news-over.gif','../../images/depts-over.gif','../../images/workers-over.gif','../../images/surgery-over.gif','../../images/physther-over.gif','../../images/score-over.gif','../../images/fellow-over.gif','../../images/ptinfo-over.gif','../../images/pted-over.gif','../../images/testimon-over.gif','../../images/insur-over.gif','../../images/forms-over.gif','../../images/contact-over.gif','../../images/home-over.gif')">
<div id="wrap"><table width="781" height="730" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
		<td colspan="3" valign="top">
			<img src="../../images/logo.jpg" alt="Southern California Orthopedic Institute" width="312" height="150"  border="0" usemap="#Map"></td>
<td valign="top">
			<img src="../../images/hurdles.jpg" width="468" height="150"></td>
<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="150"></td>
</tr>
	<tr>
		<td rowspan="20" valign="top">
			<img src="../../images/greenside.gif" width="15" height="579"></td>
<td rowspan="20" valign="top" bgcolor="#FFFFFF"><?php include('includes/sidenav.php'); ?></td>
	  <td colspan="2" rowspan="20" valign="top" bgcolor="#F0F0F0" class="tablepad"><h1>The
	      Physicians of SCOI: Administration</h1>
	    <p class="sideNavSectionBG"><?php echo $row_rsSectionTitle['category']; ?></p>
		<p>Currently working on Physician: <strong><?php echo $row_rsMainIDDesc['firstname']; ?> <?php if ($row_rsMainIDDesc['mi']<>"")  {echo "".$row_rsMainIDDesc['mi']."";} ?> <?php echo $row_rsMainIDDesc['lastname']; ?></strong> (ID: <?php echo $row_rsMainIDDesc['main_id']; ?>)
	    <form method="POST" name="Form1" class="form" action="<?php echo $editFormAction; ?>"  enctype="multipart/form-data" onSubmit="FX_processPop();">
      <fieldset>
 
			<legend>SPECIALTIES</legend>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
  
<tr>
  <td valign="top" align="right" width="200">
			  <dt class="formRequired">
				
			  <strong>Specialty:<br>
</strong>(hold down the Ctrl key to select more than one) </dt>			</td>
  <td valign="top" align="left" width="300">
<select name="spec_id[]" multiple="multiple">
<?php
do {  
?>
<option value="<?php echo $row_rsSpecialties['spec_id']?>"><?php echo $row_rsSpecialties['specialty']?></option>
<?php
} while ($row_rsSpecialties = mysql_fetch_assoc($rsSpecialties));
  $rows = mysql_num_rows($rsSpecialties);
  if($rows > 0) {
      mysql_data_seek($rsSpecialties, 0);
	  $row_rsSpecialties = mysql_fetch_assoc($rsSpecialties);
  }
?>
</select>
<input name="doc_id" type="hidden" value="<?php echo $row_rsMainIDDesc['main_id']; ?>">
</td>
  </tr>
</table>
</fieldset>
 
      <p>
  <input type="submit" name="Submit" value="Add Physician Photo &gt;&gt;">
  &nbsp;
  <input type="reset" name="Submit2" value="Start Over">
 
  <input type="hidden" name="MM_insert" value="Form1">
</p>
<p align="center">&nbsp;</p>
	
	        
      <input type="hidden" name="MM_insert" value="Form1">
</form>
	    <p>
	    
	    </p>
		<p>&nbsp;</p></td>
<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="29"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="19"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="22"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="24"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="19"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="19"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="21"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="23"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="21"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="19"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="21"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="2"></td>
	</tr>
	<tr>
	  <td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="17"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="28"></td>
	</tr>
	<tr>
	  <td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="195"></td>
	</tr>
	<tr>
		<td>
			<img src="../../images/greenside.gif" width="15" height="1"></td>
		<td>
			<img src="../../images/spacer.gif" width="222" height="1"></td>
		<td>
			<img src="../../images/spacer.gif" width="75" height="1"></td>
		<td>
			<img src="../../images/spacer.gif" width="468" height="1"></td>
		<td bgcolor="#bdbdbd"></td>
	</tr>
  <tr>
    <td colspan="4" bgcolor="#00A84A"><!-- #BeginLibraryItem "/Library/botm.lbi" --><p>&nbsp;</p>
    <p align="center" class="w"><a href="../../services.htm"  class="w">Orthopedic Services</a> | <a href="../index.php" class="w">Our Physicians</a> |  <a href="../../scoilocs.htm" class="w">Locations</a> | <a href="../../news/index.html" class="w">News/Events</a> | 
      <a href="../../workcomp.htm" class="w">Workers Compensation</a> <br>
      <a href="../../surgcenter.htm" class="w">Outpatient Surgery</a> | 
  <a href="../../rehab.htm" class="w">Physical Therapy</a> |  <a href="../../scorehom.htm" class="w">SCORE</a> | <a href="../../fellow.htm" class="w">Fellowship Program</a> | <a href="../../faqs.htm" class="w">Patient Education</a>  <br>
       <a href="../../testimonials.htm" class="w">Testimonials</a> | 
<a href="../../billing.htm" class="w">Insurance/Billing</a>  | <a href="../../forms/index.html" class="w">Forms</a> | <a href="../../apptform.htm" class="w">Request Appointment</a> | <a href="../../privacy.htm" class="w">Privacy Statement</a> | <a href="../../index.html" class="w">Home</a></p>
<p align="center" class="w"><span class="g">Material on this website
      copyright &copy;2008 Southern California Orthopedic Institute. <br>
      6815 Noble Avenue &bull; Van Nuys, California 91405 &bull; (818) 901-6600 <br>
No part of this site may be reproduced without express written consent of 
  SCOI.<br>
  <i>For more information send email to</i></span><i> <a href="mailto:&#109;&#111;&#114;&#101;&#105;&#110;&#102;&#111;&#064;&#115;&#099;&#111;&#105;&#046;&#099;&#111;&#109;" class="g">&#109;&#111;&#114;&#101;&#105;&#110;&#102;&#111;&#064;&#115;&#099;&#111;&#105;&#046;&#099;&#111;&#109;</a></i></p>
    <p></p><!-- #EndLibraryItem --><p>&nbsp;</p>    </td>
<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="1"></td>
  </tr>
</table>
</div>
<map name="Map"><area shape="rect" coords="28,33,296,87" href="../../index.html">
</map>
</body>
</html>
<?php
 
mysql_free_result($rsSpecialties);
 
mysql_free_result($rsLocations);
 
mysql_free_result($rsSectionTitle);
 
mysql_free_result($rsMainIDDesc);
?>

Open in new window

0
 

Author Comment

by:phillystyle123
ID: 21783251
don't think my last post was clear - i meant:

although i'm selecting multiple selections my code is only insterting one record into the db - i need it to insert all the selections i'm making.
0
 

Author Comment

by:phillystyle123
ID: 21798509
i've tried a couple of other things but my code is still only inserting one record into the table even though I'm selecting multiple records - please advise!  thanks!!!
<?php require_once('../../Connections/SCOI.php'); ?>
<?php
 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "Form1")) {
foreach ($_POST['spec_id'] as $val){
  $insertSQL = sprintf("INSERT INTO docspec (doc_id, spec_id) VALUES (%s, %s)",
                       GetSQLValueString($_POST['doc_id'], "int"),
                       GetSQLValueString($val, "int"));
 }
  mysql_select_db($database_SCOI, $SCOI);
  $Result1 = mysql_query($insertSQL, $SCOI) or die(mysql_error());
 
  $insertGoTo = "add3.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
 
 
 
mysql_select_db($database_SCOI, $SCOI);
$query_rsSpecialties = "SELECT specialty, spec_id FROM specialties ORDER BY specialty ASC";
$rsSpecialties = mysql_query($query_rsSpecialties, $SCOI) or die(mysql_error());
$row_rsSpecialties = mysql_fetch_assoc($rsSpecialties);
$totalRows_rsSpecialties = mysql_num_rows($rsSpecialties);
 
mysql_select_db($database_SCOI, $SCOI);
$query_rsLocations = "SELECT location, loc_id FROM locations ORDER BY location ASC";
$rsLocations = mysql_query($query_rsLocations, $SCOI) or die(mysql_error());
$row_rsLocations = mysql_fetch_assoc($rsLocations);
$totalRows_rsLocations = mysql_num_rows($rsLocations);
 
mysql_select_db($database_SCOI, $SCOI);
$query_rsSectionTitle = "SELECT category FROM admin_categories WHERE section_id = '1' AND cat_id = '1'";
$rsSectionTitle = mysql_query($query_rsSectionTitle, $SCOI) or die(mysql_error());
$row_rsSectionTitle = mysql_fetch_assoc($rsSectionTitle);
$totalRows_rsSectionTitle = mysql_num_rows($rsSectionTitle);
 
mysql_select_db($database_SCOI, $SCOI);
$query_rsMainIDDesc = "SELECT main_id, lastname, firstname, mi FROM doctors ORDER BY main_id DESC";
$rsMainIDDesc = mysql_query($query_rsMainIDDesc, $SCOI) or die(mysql_error());
$row_rsMainIDDesc = mysql_fetch_assoc($rsMainIDDesc);
$totalRows_rsMainIDDesc = mysql_num_rows($rsMainIDDesc);
?><html>
<head>
<title>The Physicians of SCOI  - The Southern California Orthopedic Institute</title>
 
<meta name="keywords" content="orthopedic surgeon, orthopedic surgery, los angeles, southern california, arthroscopy, physical therapy, sports medicine, occupational therapy, knee pain, knee injuries, neurology, knee surgery, spine, knee, physical therapist, knee injury, orthopedics, rehabilitation, neurosurgery, vocational rehabilitation, cervical spine, human spine, spine anatomy, lumbar spine, spine surgery, knee arthroscopy, acl rehabilitation, knee rehabilitation, orthopedic medicine, shoulder arthroscopy, orthopedic answers, arthritis, rheumatoid arthritis, knee surgery, shoulder pain, frozen shoulder, swollen ankles, acl, shoulder injuries, joint pain, back surgery, sprained ankle, ankle injuries, shoulder, shoulder surgery, arthritis treatment, degenerative joint disease, acl surgery, ankle sprain, orthopaedics, acl injuries, acl reconstruction, orthopaedic, orthopaedic surgery, orthopaedic surgeons, anatomy, knee, shoulder, ankle, anterior cruciate ligament, ACL, rotator cuff, arthritis, spine, carpal tunnel, scoliosis, hip replacement, knee replacement, joint replacement, osteoporosis">
 
<meta name="description" content="The Southern California Orthopedic Institute (SCOI) - serving the Los Angeles and San Fernando Valley California in orthopedic surgery, sports medicine, knee and shoulder surgery, joint replacement, MRI, and physical rehabilitation.">
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="../../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="../../style.css" rel="stylesheet" type="text/css">
 
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style></head>
<body bgcolor="#bdbdbd" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../../images/about-over.gif','../../images/services-over.gif','../../images/physicians-over.gif','../../images/locats-over.gif','../../images/news-over.gif','../../images/depts-over.gif','../../images/workers-over.gif','../../images/surgery-over.gif','../../images/physther-over.gif','../../images/score-over.gif','../../images/fellow-over.gif','../../images/ptinfo-over.gif','../../images/pted-over.gif','../../images/testimon-over.gif','../../images/insur-over.gif','../../images/forms-over.gif','../../images/contact-over.gif','../../images/home-over.gif')">
<div id="wrap"><table width="781" height="730" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
		<td colspan="3" valign="top">
			<img src="../../images/logo.jpg" alt="Southern California Orthopedic Institute" width="312" height="150"  border="0" usemap="#Map"></td>
<td valign="top">
			<img src="../../images/hurdles.jpg" width="468" height="150"></td>
<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="150"></td>
</tr>
	<tr>
		<td rowspan="20" valign="top">
			<img src="../../images/greenside.gif" width="15" height="579"></td>
<td rowspan="20" valign="top" bgcolor="#FFFFFF"><?php include('includes/sidenav.php'); ?></td>
	  <td colspan="2" rowspan="20" valign="top" bgcolor="#F0F0F0" class="tablepad"><h1>The
	      Physicians of SCOI: Administration</h1>
	    <p class="sideNavSectionBG"><?php echo $row_rsSectionTitle['category']; ?></p>
		<p>Currently working on Physician: <strong><?php echo $row_rsMainIDDesc['firstname']; ?> <?php if ($row_rsMainIDDesc['mi']<>"")  {echo "".$row_rsMainIDDesc['mi']."";} ?> <?php echo $row_rsMainIDDesc['lastname']; ?></strong> (ID: <?php echo $row_rsMainIDDesc['main_id']; ?>)
	    <form method="POST" name="Form1" class="form" action="<?php echo $editFormAction; ?>"  enctype="multipart/form-data">
      <fieldset>
 
			<legend>SPECIALTIES</legend>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
  
<tr>
  <td valign="top" align="right" width="200">
			  <dt class="formRequired">
				
			  <strong>Specialty:<br>
</strong>(hold down the Ctrl key to select more than one) </dt>			</td>
  <td valign="top" align="left" width="300">
<select name="spec_id[]" multiple="multiple">
<?php
do {  
?>
<option value="<?php echo $row_rsSpecialties['spec_id']?>"<?php if (!(strcmp($row_rsSpecialties['spec_id'], $row_rsSpecialties['spec_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsSpecialties['specialty']?></option>
<?php
} while ($row_rsSpecialties = mysql_fetch_assoc($rsSpecialties));
  $rows = mysql_num_rows($rsSpecialties);
  if($rows > 0) {
      mysql_data_seek($rsSpecialties, 0);
	  $row_rsSpecialties = mysql_fetch_assoc($rsSpecialties);
  }
?>
</select>
<input name="doc_id" type="hidden" value="<?php echo $row_rsMainIDDesc['main_id']; ?>">
</td>
  </tr>
</table>
</fieldset>
 
      <p>
  <input type="submit" name="Submit" value="Add Specialties &amp; Continue &gt;&gt;">
  &nbsp;
  <input type="reset" name="Submit2" value="Start Over">
 
  <input type="hidden" name="MM_insert" value="Form1">
</p>
<p align="center">&nbsp;</p>
	
	        
      <input type="hidden" name="MM_insert" value="Form1">
</form>
	    <p>
	    
	    </p>
		<p>&nbsp;</p></td>
<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="29"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="19"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="22"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="24"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="19"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="19"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="21"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="23"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="21"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="19"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="21"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="2"></td>
	</tr>
	<tr>
	  <td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="17"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="20"></td>
	</tr>
	<tr>
		<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="28"></td>
	</tr>
	<tr>
	  <td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="195"></td>
	</tr>
	<tr>
		<td>
			<img src="../../images/greenside.gif" width="15" height="1"></td>
		<td>
			<img src="../../images/spacer.gif" width="222" height="1"></td>
		<td>
			<img src="../../images/spacer.gif" width="75" height="1"></td>
		<td>
			<img src="../../images/spacer.gif" width="468" height="1"></td>
		<td bgcolor="#bdbdbd"></td>
	</tr>
  <tr>
    <td colspan="4" bgcolor="#00A84A"><!-- #BeginLibraryItem "/Library/botm.lbi" --><p>&nbsp;</p>
    <p align="center" class="w"><a href="../../services.htm"  class="w">Orthopedic Services</a> | <a href="../index.php" class="w">Our Physicians</a> |  <a href="../../scoilocs.htm" class="w">Locations</a> | <a href="../../news/index.html" class="w">News/Events</a> | 
      <a href="../../workcomp.htm" class="w">Workers Compensation</a> <br>
      <a href="../../surgcenter.htm" class="w">Outpatient Surgery</a> | 
  <a href="../../rehab.htm" class="w">Physical Therapy</a> |  <a href="../../scorehom.htm" class="w">SCORE</a> | <a href="../../fellow.htm" class="w">Fellowship Program</a> | <a href="../../faqs.htm" class="w">Patient Education</a>  <br>
       <a href="../../testimonials.htm" class="w">Testimonials</a> | 
<a href="../../billing.htm" class="w">Insurance/Billing</a>  | <a href="../../forms/index.html" class="w">Forms</a> | <a href="../../apptform.htm" class="w">Request Appointment</a> | <a href="../../privacy.htm" class="w">Privacy Statement</a> | <a href="../../index.html" class="w">Home</a></p>
<p align="center" class="w"><span class="g">Material on this website
      copyright &copy;2008 Southern California Orthopedic Institute. <br>
      6815 Noble Avenue &bull; Van Nuys, California 91405 &bull; (818) 901-6600 <br>
No part of this site may be reproduced without express written consent of 
  SCOI.<br>
  <i>For more information send email to</i></span><i> <a href="mailto:&#109;&#111;&#114;&#101;&#105;&#110;&#102;&#111;&#064;&#115;&#099;&#111;&#105;&#046;&#099;&#111;&#109;" class="g">&#109;&#111;&#114;&#101;&#105;&#110;&#102;&#111;&#064;&#115;&#099;&#111;&#105;&#046;&#099;&#111;&#109;</a></i></p>
    <p></p><!-- #EndLibraryItem --><p>&nbsp;</p>    </td>
<td bgcolor="#bdbdbd">
			<img src="../../images/spacer.gif" width="1" height="1"></td>
  </tr>
</table>
</div>
<map name="Map"><area shape="rect" coords="28,33,296,87" href="../../index.html">
</map>
</body>
</html>
<?php
 
mysql_free_result($rsSpecialties);
 
mysql_free_result($rsLocations);
 
mysql_free_result($rsSectionTitle);
 
mysql_free_result($rsMainIDDesc);
?>

Open in new window

0
 

Author Comment

by:phillystyle123
ID: 21798589
ok - the only thing missing in your code is this:

 if ($val!=''){

after i added that, i was able to insert multiple records.

thanks for the help!
0
 

Author Closing Comment

by:phillystyle123
ID: 31465981
thanks afzz!
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question