...

View Full Version : Unable to delete



chaychie
07-05-2011, 04:58 AM
Hi all!

I created a form where users are allowed to delete a specific row of data by clicking the "cancel" button from the drop down menu. However, I have a problem deleting my data using the javascript. Apparently, I only able to delete the first row of the data but not for the rest!

The following is the code i have:



<html>
<body style="background-color:#E0FFFF;">


<script language="javascript" >
<!-- hide
function submitRequest(val) {
document.forms[0].submit();
}

// end hide -->
</script>

<?php

$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_course", $con);

$result = mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode");
$result1 = mysql_query("SELECT * FROM Courses ORDER BY Year, Sem, CourseCode");

echo "<table border='1' cellpadding='2' cellspacing='0'>
<tr>
<th>CourseCode</th>
<th>CourseName</th>
<th>Year</th>
<th>Sem</th>
<th>Grade</th>
<th>Option</th>
</tr>";

?>

<?php

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['CourseCode'] . "</td>";
echo "<td>" . $row['CourseName'] . "</td>";
echo "<td>" . $row['Year'] . "</td>";
echo "<td>" . $row['Sem'] . "</td>";
echo "<td>" . $row['Grade'] . "</td>";
echo "<td>";

?>
<?php
?>

<form name="form1" action="submitDelete.php" method="post">
<select name="cancel" onchange="submitRequest(this.value);">
<option value=> </option>
<option value="<?php echo $row['CourseName'];?>">Cancel</option>
</select>
</form>

<?php
echo "</td>";
echo "</tr>";
}

echo "</table>";

mysql_close($con);
?>

<br/>
<br/>

</body>
</html>

Thanks in advance!

Kor
07-05-2011, 10:35 AM
Apparently there is no javascript delete function within your code. It might be a php feature of this kind, but no javascript visible there, except a small code which simply submits the form's values to a php file.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum