Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-03-2012, 08:23 PM   PM User | #1
MaDmiX
Regular Coder

 
Join Date: Feb 2012
Location: Charlotte, NC
Posts: 104
Thanks: 26
Thanked 0 Times in 0 Posts
MaDmiX is an unknown quantity at this point
Stumped creating a delete records routine

Hi All,

I am using Dreamweaver CS5 to build my site. I am working on a delete records routine. Basically I have a dynamic table listing my detail records (this is a recordset from a table linked to a parent table and the parent record is also on my page) and a delete link for each detail record that points to a logic page which does the deletion and then redirects back to the records page. I created a session variable on the logic page to hold the record number of the parent record. This gets sent via a URL parameter along with the record ID of the record to be deleted.

Whew...

Everything is working and the correct record is being deleted but I am having trouble with the redirect. I embedded the session variable into the redirect link but when I execute the deletion I am being redirected back to the records page (as I should) but the page has no records.

Here is the code I am using. I think the problem lies in my redirect but I don't know what the error could be.

Thanks in advance for any help.

Kind regards,

Ken

Records Page:

PHP Code:
            <table id="dataTable" width="606">
                <tr id="tblHeader">
                  <th width="90" align="left" style="font-size: small;" scope="col">Start Time:</th>
                  <th width="90" align="left" style="font-size: small;" scope="col">End Time:</th>
                  <th width="90" align="left" style="font-size: small;" scope="col">Material ID:</th>
                  <th width="320" align="left" style="font-size: small;" scope="col">Title:</th>    
                </tr>
            <tbody>
              <?php do { ?>
                <tr class="varianceCells">
                  <td align="left"> <?php echo $row_rstAffectedProg['StartTime']; ?></td>
                  <td align="left"> <?php echo $row_rstAffectedProg['EndTime']; ?></td>
                  <td align="left"> <?php echo $row_rstAffectedProg['MaterialID']; ?></td>
                  <td align="left"> <?php echo $row_rstAffectedProg['Title']; ?></td>
                  <td><a href="delete-affected-prog.php?tblAffectedProgID=<?php echo $row_rstAffectedProg['tblAffectedProgID']; ?>&amp;tblOnAirActivityID=<?php echo $row_rstAffectedProg['tblOnAirActivityID']; ?>">Delete</a></td>
                </tr>
                <?php } while ($row_rstAffectedProg mysql_fetch_assoc($rstAffectedProg)); ?>
            </tbody>    
            </table>
Logic Page:

PHP Code:
<?php require_once('Connections/connAirtrackII.php'); ?>
<?php
session_start
();
$_SESSION["tblOnAirActivityID"] = $_GET["tblOnAirActivityID"];
if (!
function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

if ((isset(
$_GET['tblAffectedProgID'])) && ($_GET['tblAffectedProgID'] != "")) {
  
$deleteSQL sprintf("DELETE FROM tblaffectedprog WHERE tblAffectedProgID=%s",
                       
GetSQLValueString($_GET['tblAffectedProgID'], "int"));

  
mysql_select_db($database_connAirtrackII$connAirtrackII);
  
$Result1 mysql_query($deleteSQL$connAirtrackII) or die(mysql_error());

  
$deleteGoTo "on-air-update-form.php?id=".$tblOnAirActivityID;
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$deleteGoTo .= (strpos($deleteGoTo'?')) ? "&" "?";
    
$deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$deleteGoTo));
}
?>
MaDmiX is offline   Reply With Quote
Old 07-03-2012, 09:04 PM   PM User | #2
MaDmiX
Regular Coder

 
Join Date: Feb 2012
Location: Charlotte, NC
Posts: 104
Thanks: 26
Thanked 0 Times in 0 Posts
MaDmiX is an unknown quantity at this point
Nevermind... Got it sorted. I didn't need the session variable after all as dreamweaver appends the URL varibles that are received by the logic page to the redirect URL. Once I removed the session variable and the call to it from the redirect link everything worked perfectly.
MaDmiX is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:20 AM.


Advertisement
Log in to turn off these ads.