I am trying to do an add/edit/delete page.. Right now, I only have two cases, one for the user input form (default), and the insert case (addsave) which should execute the sql insert when the form is submitted.
Well, I recieve no errors but there seem to be no inserts. Is my case statement right? I can't find anyhting wrong as to why it would not be updating the db..
below is the code I am working with
<? include "../inc/conn.php"; ?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/ffc.css">
</head>
<?
switch ($action)
{
case "addsave":
$imp_id = addslashes($imp_id);
$imp_cat = addslashes($imp_cat);
$imp_cond = addslashes($imp_cond);
$imp_make = addslashes($imp_make);
$imp_model = addslashes($imp_model);
$imp_serial = addslashes($imp_serial);
$imp_desc1 = addslashes($imp_desc1);
$imp_desc2 = addslashes($imp_desc2);
$imp_desc3 = addslashes($imp_desc3);
$imp_desc4 = addslashes($imp_desc4);
$imp_desc5 = addslashes($imp_desc5);
$imp_desc6 = addslashes($imp_desc6);
$connAdd = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$dbAdd = mysql_select_db($database,$connAdd)
or die("couldn't select database");
$add = "INSERT INTO `imp` (`imp_id`,`imp_cat`,`imp_cond`,`imp_make`,`imp_model`,`imp_serial`,`imp_desc1`,`imp_desc2`,`imp_desc3`,`imp_desc4`,`imp_desc5`,`imp_desc6`) VALUES ('$imp_id','$imp_cat','$imp_cond','$imp_make','$imp_model','$imp_serial','$imp_desc1','$imp_desc2','$imp_desc3','$imp_desc4','$imp_desc5','$imp_desc6')";
if(!mysql_query($add)) {
echo "Insertion into database failed.";
} else {
echo "Insertion into database was successful.";
}
default:
?>
<div class="left-body-container">
<div class="left-body-main">
<h3> Add a New Implement </h3>
<!-- Category Table -->
<form method="post" action="impadd.php?action=addsave" name="addForm" enctype="multipart/form-data">
<table width="100%" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="50%" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-bottom-width: 1">
<b>Select Category<b></td>
<td width="50%"> </td>
</tr>
<tr>
<td width="100%" colspan="2" style="border: 1px solid #C0C0C0">
<table>
<?
/* Build Category Checkboxes */
$connCat = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$dbCat = mysql_select_db($database,$connCat)
or die("couldn't select database");
$fillCat = "SELECT * FROM cat ORDER BY cat_name";
$rsCat = mysql_query($fillCat)
or die("couldn't execute query");
// $i - generic counter for counting columns
$i = 0;
// $column_max - number of columns desired
$column_max = 4;
echo '<tr>';
while ($row = mysql_fetch_array($rsCat))
{
$i++;
if ($i > $column_max)
{
echo '</tr><tr>';
$i = 1;
}
echo "<td>";
extract($row);
echo "<input type='radio' name='imp_cat' value='$cat_id'>$cat_name\n";
echo "</td>";
}
echo "</tr>";
?>
</table>
</td>
</tr>
</table>
<p>
<!-- Condition Table -->
<table width="100%" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="50%" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-bottom-width: 1">
<b>Select Condition<b></td>
<td width="50%"> </td>
</tr>
<tr>
<td width="100%" colspan="2" style="border: 1px solid #C0C0C0">
<table>
<?
/* Build Condition Checkboxes */
$connCond = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$dbCond = mysql_select_db($database,$connCat)
or die("couldn't select database");
$fillCond = "SELECT * FROM cond ORDER BY cond_name";
$rsCond = mysql_query($fillCond)
or die("couldn't execute fill condition query");
// $i - generic counter for counting columns
$i = 0;
// $column_max - number of columns desired
$column_max = 4;
echo '<tr>';
while ($row = mysql_fetch_array($rsCond))
{
$i++;
if ($i > $column_max)
{
echo '</tr><tr>';
$i = 1;
}
echo "<td>";
extract($row);
echo "<input type='radio' name='imp_cond' value='$cond_id'>$cond_name\n";
echo "</td>";
}
echo "</tr>";
?>
</table>
</td>
</tr>
</table>
<p>
<!-- END CONDITION TABLE -->
<!-- Make Table -->
<table width="100%" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="50%" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-bottom-width: 1">
<b>Select Make<b></td>
<td width="50%"> </td>
</tr>
<tr>
<td width="100%" colspan="2" style="border: 1px solid #C0C0C0">
<table>
<?
/* Build Make Checkboxes */
$connMake = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$dbMake = mysql_select_db($database,$connCat)
or die("couldn't select database");
$fillMake = "SELECT * FROM make ORDER BY make_name";
$rsMake = mysql_query($fillMake)
or die("couldn't execute fill make query");
// $i - generic counter for counting columns
$i = 0;
// $column_max - number of columns desired
$column_max = 4;
echo '<tr>';
while ($row = mysql_fetch_array($rsMake))
{
$i++;
if ($i > $column_max)
{
echo '</tr><tr>';
$i = 1;
}
echo "<td>";
extract($row);
echo "<input type='radio' name='imp_make' value='$make_id'>$make_name\n";
echo "</td>";
}
echo "</tr>";
?>
</table>
</td>
</tr>
</table>
<p>
<!-- END CONDITION TABLE -->
<table>
<tr><td>Model #</td><td><input type="text" name="imp_model" size="20" maxlength="20" class="" value=""></td></tr>
<tr><td>Serial #</td><td><input type="text" name="imp_serial" size="20" maxlength="20" class="" value=""></td></tr>
<tr><td>Descriptive Statement 1</td></tr><tr><td><textarea name="imp_desc1" cols="60" rows="2" class=""></textarea></td></tr>
<tr><td>Descriptive Statement 2</td></tr><tr><td><textarea name="imp_desc2" cols="60" rows="2" class=""></textarea></td></tr>
<tr><td>Descriptive Statement 3</td></tr><tr><td><textarea name="imp_desc3" cols="60" rows="2" class=""></textarea></td></tr>
<tr><td>Descriptive Statement 4</td></tr><tr><td><textarea name="imp_desc4" cols="60" rows="2" class=""></textarea></td></tr>
<tr><td>Descriptive Statement 5</td></tr><tr><td><textarea name="imp_desc5" cols="60" rows="2" class=""></textarea></td></tr>
<tr><td>Descriptive Statement 6</td></tr><tr><td><textarea name="imp_desc5" cols="60" rows="2" class=""></textarea></td></tr>
<tr><td><input type="hidden" name="toggle" value="TRUE"></td><td><input type="submit" value="Add Record"></td></tr>
</table>
<? } ?>
</div>
<!-- END BODY DIV -->