My problem with the code below is that every time i press submit i get the default value of my switch displayed on screen. I cant see why it wont just insert into the database. $table and $qty come from another form(select boxs). Please excuse some of the echo statements, just getting really annoyed with this.
<?PHP
$table=$HTTP_POST_VARS['table'];
$qty=$HTTP_POST_VARS['qty'];
$lecname=$HTTP_POST_VARS['lecname'];
$lecurl1=$HTTP_POST_VARS['lecurl1'];
$lecurl2=$HTTP_POST_VARS['lecurl2'];
$lectureNumber = 0;
$Number=1;
include ("../Connections/test_holding_inc.php");
echo "<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">";
switch ($table) {
case "Lectures";
echo "<table width=\"800\" border=\"1\" cellpadding=\"3\" cellspacing=\"2\">\n";
echo "<tr><th bgcolor = \"#CCCCFF\" colspan=\"4\" align=\"center\">Enter Lecture Note Details</th></tr>";
while ($lectureNumber < $qty)
{
echo "<tr>\n";
echo " <td width=10><b> $Number.</b></td><td width=\"270\">Lecture Notes Name: <input type =\"text\" name=\"lecname[]\" ></td>
<td width=250>Postscript URL: <input type=\"text\" name=\"lecurl1[]\" ></td>
<td width=220>PDF URL: <input type=\"text\" name=\"lecurl2[]\" ></td>\n";
echo "</tr>\n";
$lectureNumber++;
$Number++;
}
echo "</table>\n";
echo "<br>";
echo "<input type=\"HIDDEN\" NAME=\"send\" VALUE=\"submitted\">";
echo "<input type=\"Submit\" name=\"submit\" value=\"Submit\">";
echo "<input type=\"reset\" value=\"Clear me!\">";
echo "</FORM>";
#was form submitted
if ( $send != "submitted" ) {
echo "Alright";
} else {
for ($i = 0; $i < qty; $i++ ){
$sql="Insert INTO lectures (name, url1, url2) values ('$lecname[$i]', '$lecurl1[$i]', '$lecurl2[$i]')";
if (!mysql_query($sql,$connection)) {
echo "error cannot add record..hit the back buton and try again !!!<br>";
exit;
} else { echo "arse";
}}}
break;
case "Tutorials";
echo "Tutorial Table";
break;
default:
echo "Wank Shite";
exit;
}
?>