Jump to content

Update Record overwrites existing data....


Datnigz2002

Recommended Posts

I am using dreamweaver's update record feature. Only it doesn't appear to be updating the record just overwritting it. So as a work around I inserted the data so it goes underneath the "update".  Is there a way to do this without having to do that?

 

I only want to update it don't need make changes to existing data. Like a ticket system.  Example:

 

4/16/2008 John Doe

The user arrived at their distination.

 

4/18/2008 John Does

Software was installed.

 

4/21/2008

User has returned.

 

So you see I really just want to add to the record not overwrite what is there.

 

Link to comment
Share on other sites

I'm a little confused. I am new. This is what Dreamweaver put together.

 

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "tstest")) {
  $updateSQL = sprintf("UPDATE ticket_data SET `User`=%s, Subject=%s, Location=%s, Ticket=%s, Severity=%s, Issue_to=%s, Created_by=%s, Last_update=%s, Service_tag=%s, Support=%s, IMAC=%s, usr_last_name=%s, usr_first_name=%s, usr_phone=%s, Request_type=%s, Status=%s, qdue_date=%s WHERE 'table_to_check_against'='Ticket_number=%s",
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['subject'], "text"),
                       GetSQLValueString($_POST['location'], "text"),
                       GetSQLValueString($_POST['ticket_body'], "text"),
                       GetSQLValueString($_POST['severity'], "text"),
                       GetSQLValueString($_POST['tech'], "text"),
                       GetSQLValueString($_POST['creator'], "text"),
                       GetSQLValueString($_POST['last_update'], "text"),
                       GetSQLValueString($_POST['service_tag'], "text"),
                       GetSQLValueString($_POST['support'], "text"),
                       GetSQLValueString($_POST['imac'], "text"),
                       GetSQLValueString($_POST['usr_lastname'], "text"),
                       GetSQLValueString($_POST['usr_firstname'], "text"),
                       GetSQLValueString($_POST['usr_num'], "text"),
                       GetSQLValueString($_POST['request_type'], "text"),
                       GetSQLValueString($_POST['Status'], "text"),
                       GetSQLValueString($_POST['input1'], "text"),
                       GetSQLValueString($_POST['ticket_number'], "text"));

 

How/where do I incorperate/integrate

 <?php UPDATE `table_name` SET `table_row`=`table_row`.'post_data' 

WHERE `table_to_check_against`='This_value'; 
?> 

without messing up what Dreamweaver generated for me....?

Link to comment
Share on other sites

Well, the Insert command will add a new record all together.... What I am looking for is to add to the record without over writing what is there.. Like a ticket system. Exmple:

 

If I INSERT a record (123). I would like to UPDATE the record later with (456) without overwriting (123)

Link to comment
Share on other sites

I hate to tell you this, but I'd suggest really just writing it from scratch.  I've never used Dreamweaver, but they made us use Frontpage for Web Design in the beginning of the year (I told my instructor how much it sucked so I didn't have to use it), so I know that Frontpage puts all this garbage in the top of the document and is very...awkward.  Just get a text editor and start coding. =P

 

Link to comment
Share on other sites

Umm, where are you getting GetSQLValueString from?  Is it a dreamweaver function that it's throwing into your code?  See, that's why I hate these WYSIWYG and "here let me make the code for you" editors. =/ 

 

And I don't know why they'd use sprintf and put all those strings at the end of the function and update like, every field.  Whatever. @_@

Link to comment
Share on other sites

Not to worry I have a undo button. All I know is that it puts in when you create a update record server behavior. That part looks like it comes in when DW asks you what to submit the data as... (text, checkbox Y:M, Integer, etc) I suppose it means it is "Getting" the data that was typed in the textfields before you submit it. It doesn't appear to be relivent to the part the action I'm looking to take place.

Link to comment
Share on other sites

Its not doing anything wrong I just want it to update a different way. Here is one of my posts....

 

Well, the Insert command will add a new record all together.... What I am looking for is to add to the record without over writing what is there.. Like a ticket system. Exmple:

 

If I INSERT a record (123). I would like to UPDATE the record later with (456) without overwriting (123)

 

So later if I view the record it looks like...

 

(123)

(456)

 

As it stands now it DOES update the record just not the way I would like it to. I want it to retain the existing information within the record and just add the update to it. (Stacking Quaters)

Link to comment
Share on other sites

To me this LOOKS right but I just don't understand where to put it or what to change about it.  Is "New data" a variable or something or is it part of the query. I really am starting new here..

 

"UPDATE table SET column = CONCAT(column, "New data") WHERE condition = true;"

 

Link to comment
Share on other sites

I don't understand was that supposed to help? Yes I remember him saying that.... and I explained that GetSQLValue is used to display the current information in the record inside of the textfields...

 

Give us the code in the function.  Find it somehow. =/

Link to comment
Share on other sites

What is a function? lol,, duh... I will post where I know the whole thing starts and ends.

Thanks for your help!!

 


<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "tstest")) {
  $updateSQL = sprintf("UPDATE ticket_data SET `User`=%s, Subject=%s, Location=%s, Ticket=%s, Severity=%s, Issue_to=%s, Created_by=%s, Last_update=%s, Service_tag=%s, Support=%s, IMAC=%s, usr_last_name=%s, usr_first_name=%s, usr_phone=%s, Request_type=%s, Status=%s, qdue_date=%s WHERE Ticket_number=%s",
?>

Link to comment
Share on other sites

Datnigz2002, your statement of updating a record vs inserting a record is faulty and the post suggesting to concatenate information into a field is definitely not what anyone should do. It makes it impossible to directly do anything with that data, such as order it by date and you must then write custom logic to separate it and display it.

 

One record in a database holds one defined record of data. An update by definition, replaces existing data with new data.

 

For your example -

 

4/16/2008 John Doe

The user arrived at their destination.

 

4/18/2008 John Doe

Software was installed.

 

4/21/2008 John Doe

User has returned.

 

These are three separate pieces of information about one (or more) person. Each piece of information contains the date it happened, what happened, and a piece of information relating that data to who it happened to.

 

Your design needs a user table (with at least a user_id, the user's first name, and the user's last name, and any other data specific to that user) and an "event" table (with at least an event_id, a user_id, a date, and a field to record what happened.) The user_id in the "event" table relates all the "even" records to the user they apply to.

Link to comment
Share on other sites

Thanks that helps a great deal. Only you are not understanding what I want to do. I want to update a field not a record in this this way. All my info can be sorted just fine but I will never need to sort this field. The field is nothing more than the body of a trouble ticket. But thanks for your definition. Any help????

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.