hello friends i want to add confirmation box to my delete option in the pagination code so when the user want to delete the record before deleting it may as for the option yes or no...below is my code and the code in bold is the delete code....

     mysql_connect("localhost","root","")or die(mysql_error());
     mysql_select_db("project")or die(mysql_error());

	   if($_GET['action']=='del' & $_GET['id']!="")
	 mysql_query("DELETE FROM stu_info WHERE id='".$_GET['id']."'");	

	 $per_page = 1;

     $pages_query = mysql_query("SELECT COUNT('id') FROM `stu_info`");
    $pages = ceil(mysql_result($pages_query, 0)/$per_page);
    $page = (isset($_GET['page'])) ? (int)$_GET['page'] :1 ;
     $start = ($page-1)* $per_page;
 // $search = $_GET['go'];	
    $search = $_POST['search'];
   $dropdown = $_POST['type'];

$query = mysql_query("SELECT `id`,`name`, `lastname`,`admission`,`day_list`,`month_list`,`year_list`,`gender`,`Cityy` FROM stu_info WHERE $dropdown='$search'") ;

	if($search=='' || $dropdown==''){
$query = mysql_query("SELECT `id`,`name`, `lastname`,`admission`,`day_list`,`month_list`,`year_list`,`gender`,`Cityy`  FROM `stu_info` LIMIT $start, $per_page");


$id = $query_row['id'] ;
$ad_title = $query_row['name'] ;
$lastname = $query_row['lastname'];
$admission = $query_row['admission'];
$day = $query_row['day_list'];
$month = $query_row['month_list'];
$year = $query_row['year_list'];
$gender = $query_row['gender'];
$city = $query_row['Cityy'];

$display_block .= "

  <tr align='center'>

  <td><div class='view'><a href='stuInfoEdit.php?id=$id&action=view'><img src='edit.jpg'style='height: 23px; width: 23px;'/> </a><a href='db.php?id=$id&action=view'><img src='search.jpg'style='height: 23px; width: 23px;'/> </a>[B]<a href='viewData.php?id=$id&action=del' ><img src='deletered.png'style='height: 20px; width: 20px;' /></a>[/B]
  </tr>" ;
echo '</table>'; 


here i have tried my own to put javascript on the delete code above


<script type="text/javascript">

function clickme(){
var hi = confirm("Are sure want to delete")

if( hi == true){

alert("Entry Deleted")
window.location = "<a href='viewData.php?id=$id&action=del' >";[B] [I]here i got the problem[/I][/B]
if(hi == false){
window.location = 'http://localhost/project/student%20info/search.php';	

please i cant figure it out the part that how to put the code on the delete link please help me

You can do the whole thing in the a tag.

The secret is to return true from the tag's onclick handler to allow the href action or false to disallow. This is made easy because confirm() itself returns true or false.

<a href="viewData.php?id=$id&action=del" onclick="return confirm('Are sure want to delete?')"><img src='deletered.png' style="height: 20px; width: 20px;" /></a>


Be a part of the DaniWeb community

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