kar2905
06-18-2009, 04:39 PM
I have a simple form of three columns : date , todo , delete
The last column is for deleting the specific entry . I am using onclick to transfer the control to a javascript function while passing the date and todo as arguments . Then in the function , i am sending query through php to mysql to delete the entry from the database . But , I am getting errors while running it
this the js function :
<script type="text/javascript">
function delete($date,$todo)
{
<?php
session_start();
include 'mysqlconnect.php';
$sql="DELETE FROM todo WHERE Date = '".$date ."' AND Todo = '".$todo."' AND user = '".$_SESSION['user']."' ";
$result=mysql_query($sql) or die(mysql_error());
?>
}
</script>
This is where I call the function :
<?php
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" ;
echo $row['Date'] ;
echo "</td>";
echo "<td>";
echo $row['Todo'] ;
echo "</td>";
echo "<td>";
?>
<input type="button" value="Delete" name="delete" onClick="delete(<?php echo $row['Date'] . ',' . $row['Todo']; ?>);" />
<?php
echo"</td>";
echo "</tr>";
}
?>
pls help
The last column is for deleting the specific entry . I am using onclick to transfer the control to a javascript function while passing the date and todo as arguments . Then in the function , i am sending query through php to mysql to delete the entry from the database . But , I am getting errors while running it
this the js function :
<script type="text/javascript">
function delete($date,$todo)
{
<?php
session_start();
include 'mysqlconnect.php';
$sql="DELETE FROM todo WHERE Date = '".$date ."' AND Todo = '".$todo."' AND user = '".$_SESSION['user']."' ";
$result=mysql_query($sql) or die(mysql_error());
?>
}
</script>
This is where I call the function :
<?php
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" ;
echo $row['Date'] ;
echo "</td>";
echo "<td>";
echo $row['Todo'] ;
echo "</td>";
echo "<td>";
?>
<input type="button" value="Delete" name="delete" onClick="delete(<?php echo $row['Date'] . ',' . $row['Todo']; ?>);" />
<?php
echo"</td>";
echo "</tr>";
}
?>
pls help