View Full Version : Unable to delete

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:

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

<script language="javascript" >
<!-- hide
function submitRequest(val) {

// end hide -->


$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'>



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>";


<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>

echo "</td>";
echo "</tr>";

echo "</table>";




Thanks in advance!

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