I have problem with inserting multiple items from textarea into database.
The problem is when i choose multiple items from textarea and click submit button, it only store 1 item only. Suppose it must insert multiple items. My codes for the form is :
recordform.php
<form name="addsummonrecord" method="post" action="recordprocess.php" id="signup" onSubmit="return checkform(this);">
<table width="452" border="1" align="right" cellpadding="4" cellspacing="3" bordercolor="#003093" id="table">
<tr>
<td width="210" class="labelfield">Record Code:</td>
<td width="211" nowrap class="field">
<input name="recordno" type="text" size="10" maxlength="4"
class="fieldcellinput"></td>
</tr>
<tr>
<td class="labelfield">Types/Records: <br/>
<font size="1">(ctrl+click to select multiple records)</font></td>
<td nowrap>
<select name="types" size="3"multiple
class="textarea" id="summons" style="width:190px" >
<?php
$sql = "SELECT summonid, types FROM summon_types ORDER BY types";
$result = mysql_query($sql) or die ("<font color=\"#FF0000\"Query Error</font>".
mysql_error());
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['types'] . '">' .
$row ['types'] . '</option>' . "\r\n"; }
?>
</select>
</td>
</tr>
</table>
<input name="submit_rec" type="submit" class="button" id="submit_rec" value="Add New Record" >
</form>
And this is my recordprocess.php form:
<?php
extract($_POST);
include "connection.inc";
$recordno = $POST['recordno'];
$types = $POST['types'];
if(isset($_POST['submit_rec'])) {
$sql = "INSERT INTO records VALUES('$recordno', '$types')";
$results = mysql_query($sql);
if (!$results) {
echo "Unable to store data"; }
}
mysql_close();
?>
Can anyone help me???? 😕