Hello, I would like to create a confirmation box for delete. Do you want to delete this row? [Yes] [No]
How?
How to create a colorful confirmation box? ok, I find the demo link demo link
NOw, I wonder how to merge php with jquery ? So if someone click Yes it will delete the particular row, otherwise it will be cancelled.
studentmgt.php
<div id="inputberita">
<center>
<div id="title"><h2>Student Management</h2></div>
</center>
<p> </p>
<p> </p><center>
<?php
include('../../includes/koneksi.php');
//Hapus berita // undefined index: mode
if (!empty($_REQUEST['student_id']))
{
$student_id = $_REQUEST['student_id'];
// Query to get student picture filename
$result = mysql_query("SELECT newfilename FROM student WHERE student_id =".$student_id) or die(mysql_error());
$data1 = mysql_fetch_assoc($result);
$pic_filename = $data1['newfilename'];
$result = mysql_query("DELETE FROM student WHERE student_id =".$student_id) or die(mysql_error());
if($result){
unlink('../upload/'.$pic_filename);
}
$confirmation = !$result ? "Fail to delete data." : "Data has been deleted.";
}
if(!empty($_GET['search'])){
$search = $_GET['search'];
}
else
{
//$search = "";
}
?>
<div align="center">
<div style="width:700px;text-align:left;padding-top:5px;">
<?php if (isset($confirmation)) { echo $confirmation; } ?>
<form method="get" action="<?php $_SERVER['PHP_SELF'] ?>">
<br/>
<br><br>
<?php
// pagination references:
// http://www.raymondselda.com/php-pagination-script/
//Include the PS_Pagination class
include('ps_pagination.php');
//Connect to mysql db
$conn = mysql_connect('localhost','root','');
mysql_select_db('squprime',$conn);
if(!empty($search)){
$sql = "SELECT * FROM `student`
INNER JOIN `group`
ON group.group_id = student.group_id
INNER JOIN `access`
ON access.access_level_id = student.access_level_id WHERE group.group_name = '".$search."' OR student.stu_fname = '".$search."' OR stu_lname = '".$search."' OR student.stu_address = '".$search."' OR student.stu_hp = '".$search."' OR access.access_level = '".$search."' ORDER BY group_name ASC";
}else{
$sql = "SELECT * FROM `student`
INNER JOIN `group`
ON group.group_id = student.group_id
INNER JOIN `access`
ON access.access_level_id = student.access_level_id";
}
//Create a PS_Pagination object
$pager = new PS_Pagination($conn,$sql,10,10);
?>
Search: <input type="text" size="20px" name="search" value=""><br><br>
<button type="button" onClick="parent.location='studentinfo.php'">Add New Student</button><br><br>
<table id="admintable" border="1" cellpadding="2" cellspacing="0" width="900">
<tr>
<th>Group</th><th>First Name</th><th>Last Name</th><th>Address</th><th>hp</th><th>Access</th><th>Post</th>
</tr>
<?php
$i=0;
//The paginate() function returns a mysql result set
$result = $pager->paginate();
while($data = mysql_fetch_assoc($result)) {
$result2=($i%2)?'#DFA09D':'white';
echo "<tr bgcolor='$result2'>";
echo '<td>'.$data['group_name'].'</td>';
echo '<td>'.$data['stu_fname'].'</td>';
echo '<td>'.$data['stu_lname'].'</td>';
echo '<td>'.$data['stu_address'].'</a></td>';
echo '<td>'.$data['stu_hp'].'</a></td>';
echo '<td>'.$data['access_level'].'</a></td>';
echo '<td><a href="studentmgt.php?student_id='.$data['student_id'].'">Delete</a></td>';
echo '</tr>';
$i++;
}
?>
</table>
<?php //Display the full navigation in one go
echo '<br><br>';
echo $pager->renderFullNav();
?>
</form>
</div>
</div>
</center>
</div>
</div>
Thanks before.