Hi...
I'm really confused in this script given to me...
I wonder why I cannot connect to the other page when I hit the DELETE button?
I hope you can help me with this. thank you!!!
=======
<?
include('include/dbConnect.php');
include("globals/functions.php");
include('include/Pager.php');
function getShifts(){
if (isset($_GET['page'])){
$GLOBALS['page'] = $_GET['page'];
}
$limit = 5;
$qry = "SELECT *
FROM actatek_shift
";
$qryRes = mysql_query($qry);
$GLOBALS['total'] = mysql_num_rows($qryRes);
$GLOBALS['pager'] = Pager::getPagerData($GLOBALS['total'], $limit, $GLOBALS['page']);
$offset = $GLOBALS['pager']->offset;
$limit = $GLOBALS['pager']->limit;
$GLOBALS['page'] = $GLOBALS['pager']->page;
if($GLOBALS['total']>0){
$qryStr = $qry . "LIMIT $offset, $limit";
}else{
$qryStr = $qry;
}
$qryResult = mysql_query($qryStr);
if ($qryResult){
for ($i=0;$i<mysql_num_rows($qryResult);$i++){
$rs[] = mysql_fetch_assoc($qryResult);
}
return $rs;
}
}
function display_shiftList(){
$conn = connect();
$rsShift = array();
$rsShift = getShifts();?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/actatek.css" rel="stylesheet" type="text/css" />
</head>
<form id="DisplayShiftFrm" name="DisplayShiftFrm">
<table width="80%" border="0">
<tr>
<td class="title" colspan="4">Shift Maintenance</td>
</tr>
</table>
<br>
<table width="80%" border="0">
<!--PAGING-->
<tr>
<td colspan="4"><?
if ($GLOBALS['total']>5)
{
if ($GLOBALS['page'] == 1) // this is the first page - there is no previous page
echo "Previous";
else // not the first page, link to the previous page
echo "<a href=\"main.php?select=AddShift&page=" . ($GLOBALS['page'] - 1) . "\"> Previous</a>";
for ($i = 1; $i <= $GLOBALS['pager']->numPages; $i++)
{
if ($i == $GLOBALS['pager']->page)
echo " $i";
}
echo ' of '.$GLOBALS['pager']->numPages;
if ($GLOBALS['page'] == $GLOBALS['pager']->numPages) // this is the last page - there is no next page
echo " Next";
else // not the last page, link to the next page
echo " <a href=\"main.php?select=AddShift&page=" . ($GLOBALS['page'] + 1) ."\">Next</a>";
}?>
</td>
</tr>
<tr>
<!--Column Header-->
<td width="10%" class="columnHeader"><input type="checkbox" name="chk" onclick="checkUncheckAll(this)"></td>
<td width="25%" class="columnHeader">Shift Name</td>
<td width="25%" class="columnHeader">Shift Start</td>
<td width="25%" class="columnHeader">Shift End</td>
</tr>
<?
//display shift table data
foreach ($rsShift as $idShift=>$shift)
{
//alternate row colors
if(checkNum($idShift) === TRUE){
$color = "#FBB117";
}else{
$color = "#FFFFFF";
}
echo sprintf("<tr bgcolor=\"%s\"><td align=\"%s\"><input type=\"%s\" name=\"%s\" value=\"%s\" /></td>
<td align=\"%s\">%s</td>
<td align=\"%s\">%s</td>
<td align=\"%s\">%s</td></tr>", $color,
"center", "checkbox", "chk", $shift['shift_id'],
"center",$shift['shift_description'],
"center",$shift['shift_start'],
"center",$shift['shift_end']);
}
?>
</table>
<input type="submit" name="addBtn" class="btn" style="width:60px;" value="Add" />
<input type="submit" name="EditBtn" class="btn" style="width:60px;" value="Edit" onclick="conf_edit()"></input>
<input type="submit" name="DeleteBtn" class="btn" style="width:60px;" value="Delete" onclick="if(conf_delete()){ document.DisplayShiftFrm.action='main.php?select=AddShift&delete=1'}else{return false}"></input>
<!-- <input type="submit" name="DeleteBtn" class="btn" style="width:60px;" value="Delete" onclick="conf_deletes()"></input>-->
<input type="hidden" name="ShiftID">
<? if (isset($_GET['delete']) && $_GET['delete']== 1){
deleteShift(); }
else {
echo "Cannot access the deleteShift Function";
}
}?>
</form>
<??>
<script language="javascript">
function checkUncheckAll(theElement) {
var theForm = theElement.form, z = 0;
for(z=0; z<theForm.length;z++){
if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
theForm[z].checked = theElement.checked;
}
}
}
function getCheckBoxValue() {
var ctr = document.DisplayShiftFrm.chk.length;
var str = ""
for (var j = 1; j <= ctr-1; j++) {
box = eval("document.DisplayShiftFrm.chk[" + j + "]");
if(box.checked)
str = str + box.value + ",";
}
if(str != "") {
document.DisplayShiftFrm.ShiftID.value = str;
return true;
} else
return false;
}
function conf_delete() {
if(getCheckBoxValue() == true) {
if(confirm("Are you sure you want to delete the selected record(s)?"))
return true;
else
return false; }
else {
alert("Please select item to delete");
return false;
}
}
function conf_deletes() {
if (conf_delete() == true){
alert("a");}
window.location = "http://javascript.internet.com/new";
}
function conf_edit() {
var ctr = document.DisplayShiftFrm.chk.length;
var num = 0;
var str="";
for (var j = 0; j <= ctr-1; j++) {
box = eval("document.DisplayShiftFrm.chk[" + j + "]");
if(box.checked){
str = str + box.value + ",";
num = num + 1;
}
}
if(num==1) {
document.DisplayShiftFrm.ShiftID.value = str;
return true;
} else if(num>1) {
alert("Please select one item to edit.");
history.back();
return false;
} else{
alert("Please select item to edit.");
return false;
}
}
</script>
===
I just wish that after I click the delete button, i could load a function that would delete my selected list...
Thank you
Grace