Can somebody tell me why is this not inserting multiple values ($tip[], $faza[], $ocj[]) in db. The main thing this should do is when multiple chack boxes are selected there should be multiple rows with values ($tip[], $faza[], $ocj[]) inserted into db.
To be more clear, I select for instance chackbox 1,3,5, in rows where this chackboxes are selected, I then select from menu (second part of the code explain this) values for $tip[], $faza[], and after submit I need 3 ROWS in db table "ocjen_tip" each with selected values.
But all I get is values of tip, faza, ocj for last row in dynamic table from web, The best thing is that this value wasnt even selected with checkbox!!!!
global $HTTP_POST_VARS;
if (isset($HTTP_POST_VARS['izabrani']))
{
$izabrani = $HTTP_POST_VARS['izabrani'];
for($i=0; $i<count($izabrani); $i++)
{
if ($izabrani == true)
{
$tip[] = $HTTP_POST_VARS['tip_ocjenitelja'];
$faza[] = $HTTP_POST_VARS['faza'];
$ocj[] = $HTTP_POST_VARS['ocjenitelj_id'];
$sql = "INSERT INTO ocjen_tip (faza_id, tip_ocjenitelja, faza, ocjenitelj_id, ustanova_id) VALUES ('".$tNG->recordId."', '".$tip[$i]."', '".$faza[$i]."', '".$ocj[$i]."', '".$tNG->recordId."')";
mysql_select_db($tNG->databasename, $tNG->connection);
mysql_query ($sql, $tNG->connection) or die(mysql_error());
}
}
}
Selecting from dynamic table on web, This is part of the form.
<td><select name="faza" id="faza">
<?php
do {
?>
<option value="<?php echo $row_Recordset4['faza']?>"<?php if (!(strcmp($row_Recordset4['faza'], $row_Recordset4['faza_id']))) {echo "SELECTED";} ?>><?php echo $row_Recordset4['faza']?></option>
<?php
} while ($row_Recordset4 = mysql_fetch_assoc($Recordset4));
$rows = mysql_num_rows($Recordset4);
if($rows > 0) {
mysql_data_seek($Recordset4, 0);
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
}
?>
</select></td>
<td><input name="izabranitype="checkbox" id="izabrani" value="<?php echo $row_Recordset1['ocjenitelj_id']; ?>"></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>