im trying to write a script that will add multiple rows into a database based on a for loop...
here's the form that needs to be filled out:
$display_block = " <table border='0' cellpadding='2' cellspacing='0'>
<form action='$_SERVER[PHP_SELF]' method='post'>
<tr>
<td><strong>#</strong></td>
<td><strong>Song</strong></td>
<td><strong>Mp3</strong></td>
</tr>";
for ($i = 1; $i<=30; $i++) {
$display_block .= " <tr>
<td align='center'><strong>$i</strong><input name='number[$i]' type='hidden' value='$i'></td>
<td><input type='text' name='song[$i]' size='50'></td>
<td algin='center'><input name='mp3[$i]' type='checkbox' value='1'></td>
</tr>";
}
$display_block .= " <tr>
<td height='10'></td>
</tr>
<tr>
<td colspan='3' align='right'><input type='hidden' name='op' value='inserttrk'>
<input type='submit' name='submit' value='Submit'>
</td>
</tr>
</form>
</table>";
then once the form is submitted, I want it to loop through all 30 form fields and if the "song[$i]" array is filled out, i want it to insert into the database..
if the "mp3[$i]" checkbox is checked, i want it to insert its value (1) into the database, but if it is NOT filled out, i'd like it to insert 0
can anyone help me with this?