In alert box i anto show two buttons,
1. OK and
2. Cancel.
If cancel it should redirect to previous page. How?

Recommended Answers

All 4 Replies

Thank u

U're welcome :-). Once you have some code and if you get stuck, post the code you have. If you manage to finish it yourself, please mark the thread as solved.

Happy coding.

this is my view_category.php::
<!DOCTYPE html>
<html lang="en">

<head>



  </head>

  <body>
<?php
include('include/header.html');
?>





  <?php 
include('connect_category.php');
$r=mysql_query("select * from tbl_category") or die(mysql_error());
$count = mysql_num_rows($r);                                
if($count > 0)
{
?>

                                <table>
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th> Category Name</th>
                                            <th>Description</th>
                                            <th>Rack No</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>


<?php
$i=1;
while($newr=mysql_fetch_array($r))
{
$id=$newr['id'];
echo "<tr>
     <td>".$i."</td> 
    <td>".$newr['categoryname']."</td>
    <td>".$newr['description']."</td>
    <td>".$newr['rackno']."</td>

    <td> 
    <a href='edit_category.php?ed_id=".$id."'><span class='label label-info'>Edit</span></a>

    <a href='delete_category.php?del_id=".$id."'><span class='label label-important'>Delete</span></a></td>
</tr>";
?>
<?php
$i++;
}
} 
else
{
?>

<table>
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th> Category Name</th>
                                            <th>Description</th>
                                            <th>Rack No</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>


</table>
<div align="center">
No records found.
 <a href="add_category.php"> Add book to library</a>
 </div>   
<?php
}
echo '</table>';
?>
</body>


</html>


this is my delete_category.php""::

<?php
include('connect_category.php');
$del_id=$_REQUEST['del_id'];
echo '<script type="text/javascript">confirm("Are you sure want to delete?");</script>';
if(confirm)
{
mysql_query("delete from tbl_category WHERE id='$del_id'")or die(mysql_error());
echo '<script type="text/javascript">alert("Deleted sucessfully");window.location.href="view_category.php";</script>'; // header("Location: index.php");
}
else
{
echo '<script type="text/javascript">alert("You cancelled.");window.location.href="view_category.php";</script>';
}
?>
 the lese part is not working.. give me the solution
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.