Datnigz2002 Posted April 17, 2008 Share Posted April 17, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/ Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 UPDATE `table_name` SET `table_row`=`table_row`.'post_data' WHERE `table_to_check_against`='This_value'; Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-519931 Share on other sites More sharing options...
themistral Posted April 17, 2008 Share Posted April 17, 2008 I think you actually want to use the INSERT command. Have a table with date, name and action and insert the applicable values - updating will overwrite the record - that's the point of it. Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-519957 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525299 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525314 Share on other sites More sharing options...
mrdamien Posted April 23, 2008 Share Posted April 23, 2008 UPDATE table SET column = CONCAT(column, "New data") WHERE condition = true; Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525320 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 Thanks but I'm not too sure how to integrate that into what dreamweaver generated. Can you look at my code (above) and gives me an example? Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525329 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525331 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 I'd really like to get this done using Dreamweaver. How would I edit the above code to integrate your suggestion? Frontpage is a toy... (Hyundai VS Jaguar) Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525339 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525344 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 I don't even know what GetSQLValueString means its working whatever it does. I use the GUI to create the baseline stuff I need. (Tables, fields, authentifications/logins, etc.) dreamweaver is also a great code editor but I'm not which is why I'm here. (: Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525365 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 Original question: Where are you getting GetSQLValueString from? I don't want to mess up Dreamweaver's stuff until I know where it's getting that function. Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525368 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525373 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 It looks like Dreamweaver IS doing an UPDATE query. What is it doing wrong again? =/ Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525376 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525381 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525391 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 I believe GetSQLValueString was put there so that the current data within the record is displayed in the textfields so that you can actually SEE what it is your are updating in the first place? Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525405 Share on other sites More sharing options...
BlueSkyIS Posted April 23, 2008 Share Posted April 23, 2008 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. =/ Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525412 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 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... Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525421 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525428 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525433 Share on other sites More sharing options...
PFMaBiSmAd Posted April 23, 2008 Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525449 Share on other sites More sharing options...
Datnigz2002 Posted April 23, 2008 Author Share Posted April 23, 2008 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 https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-525474 Share on other sites More sharing options...
Datnigz2002 Posted April 24, 2008 Author Share Posted April 24, 2008 Hey I still haven't had any luck with this. Any help where to start would be great. I don't think I have been specific enough. I only need to do this with 1 field in the update which is "ticket" Thanks Link to comment https://forums.phpfreaks.com/topic/101621-update-record-overwrites-existing-data/#findComment-526329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.