I am trying to insert data into a MySQL table and one of the columns is inserting 'Array' instead of the array values. What am I missing, please? Thanks.
id studentname title academicdiscipline priority
012345678 TEST, NAME Array Civil 3
012345678 TEST, NAME Array Civil 1
012345678 TEST, NAME Array Civil 4
012345678 TEST, NAME Array Civil 5
012345678 TEST, NAME Array Civil 2
Here is how I insert the data into the database - which works just fine apart from the 'title' column:
if(isset($_POST['submit'])) {
$id = $_POST["id"];
$studentname = $_POST["studentname"];
$title = $_POST["title"];
$academicdiscipline = $_POST["academicdiscipline"];
$priority = $_POST["priority"];
$array = array();
foreach ($priority as $priority) {
if ($priority >=1) {
$array[] = "('$id', '$studentname', '$title', '$academicdiscipline', '$priority')"; }
$query = "INSERT INTO flux_project_selection (id, studentname, title, academicdiscipline, priority) VALUES" .implode(',', $array); }
$retval = mysql_query($query) or die(mysql_error()); }
EDIT: Here is the HTML for the form:
<table width="890" cellspacing="0">
<thead><tr>
<th></th>
<th width="250"> Title </th>
<th width="550"> Description </th>
<th width"90"> Field </th>
<th width="50"> Select </th>
</tr></thead>
<?php
$color1 = "#E9E9E9";
$color2 = "#FFFFFF";
$row_count = 0;
echo "<tr>
<td valign = \"top\" bgcolor=\"$row_color\">
<input type=\"hidden\" name=\"id[]\" value=\"$id\">
<input type=\"hidden\" name=\"studentname[]\" value=\"$studentname\"></td>
<td valign = \"top\" bgcolor=\"$row_color\">
<input type=\"hidden\" name=\"title[]\" value=\"$title\"> $title </td>
<td valign = \"top\" bgcolor=\"$row_color\">
<input type=\"hidden\" name=\"description[]\" value=\"$description\"> $description </td>
<td valign = \"top\" bgcolor=\"$row_color\">
<input type=\"hidden\" name=\"academicdiscipline[]\" value=\"$academicdiscipline\"> $academicdiscipline </td>
<td valign = \"top\" bgcolor=\"$row_color\">
<select name=\"priority[]\" class=\"priority\">
<option> </option>
<option value=\"1\"> 1 </option>
<option value=\"2\"> 2 </option>
<option value=\"3\"> 3 </option>
<option value=\"4\"> 4 </option>
<option value=\"5\"> 5 </option>
<option value=\"6\"> 6 </option>
<option value=\"7\"> 7 </option>
<option value=\"8\"> 8 </option>
<option value=\"9\"> 9 </option>
<option value=\"10\"> 10 </option>
</select>
</td></tr>
<tr bgcolor=\"#ffffff\"> </tr>
<tr bgcolor=\"#902C2E\"> </tr>";
$row_count++;
echo"<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td ><input name=\"reset\" type=\"reset\" value=\"Clear selection\"/>
<input name=\"submit\" type=\"submit\" value=\"Submit selection\"/>
</tr></table>";
?>