Current location: Hot Scripts Forums » Other Discussions » Database » Adding to Record?


Adding to Record?

Reply
  #1 (permalink)  
Old 11-02-06, 10:08 AM
tommyc325's Avatar
tommyc325 tommyc325 is offline
Wannabe Coder
 
Join Date: Sep 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Adding to Record?

i was wondering if this is possible.........

i want to be able for a user to fill out a form and when he submits it instead of adding, updating a record i want it to add to a record i already have into the db.

Example:

db record: Hello how are you.

Adding into db record: Hello how are you., Im good thanks.


Please help.
Reply With Quote
  #2 (permalink)  
Old 11-02-06, 10:35 AM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
look up UPDATE syntax in MySQL.
Reply With Quote
  #3 (permalink)  
Old 11-02-06, 10:44 AM
odi's Avatar
odi odi is offline
Newbie Coder
 
Join Date: Oct 2006
Location: Switzerland
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
when you want to update a record you need to identify it, ether by text or an ID.

If you want to do something like a reply (from your example) you can easily add a new record but define that the new record is a reply (this is done with a relation, if you need more information, ask).

If you want a concrete example it would be useful to give us more information about your table structure and the problem you're trying to solve
Reply With Quote
  #4 (permalink)  
Old 11-02-06, 10:49 AM
tommyc325's Avatar
tommyc325 tommyc325 is offline
Wannabe Coder
 
Join Date: Sep 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
yea the relation seems like what i want
Reply With Quote
  #5 (permalink)  
Old 11-02-06, 11:04 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
If you literally want to concatenate additional information onto a record in an UPDATE, take a look at the mysql CONCAT and CONCAT_WS functions.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #6 (permalink)  
Old 11-02-06, 11:45 AM
odi's Avatar
odi odi is offline
Newbie Coder
 
Join Date: Oct 2006
Location: Switzerland
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
if you want a relation for let's say a forum, you have a parent record (i.e. the first post in a thread).
All of the following records are childs. In the most basic way I can think of you need 3 collums:

-ID
-text
-parent-ID

now, for the first record you add the ID in the parent-id field as well (you can use the insert_id() function to gather the id of the just inserted record).

If a user posts a reply, you need to know on which ID he is replying (can be done using a hidden input-field):

Code:
<input type="hidden" name="parent" value="3" />
you must add something like that to your form, don't forget to set the correct value (instead of "3" you must enter the actual ID).

Then, you enter a new record and set the parent ID.

At the end you can do something like:
Code:
select text from my_table where parent='3'
to show all posts to a certain thread.

your db-records would look like that:
Code:
mysql> select * from my_table;
+----+----------------------------------+--------+
| id | text                             | parent |
+----+----------------------------------+--------+
|  1 | hello there                      |      1 |
|  2 | nice to see you                  |      1 |
|  3 | yeah, really nice                |      1 |
|  4 | I start a new thread             |      4 |
|  5 | I answer you                     |      4 |
|  6 | i ansert the first thread again! |      1 |
+----+----------------------------------+--------+
I hope that was somehow understandable...
Reply With Quote
  #7 (permalink)  
Old 11-02-06, 11:54 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Topic moved to database.
Reply With Quote
  #8 (permalink)  
Old 11-02-06, 12:17 PM
tommyc325's Avatar
tommyc325 tommyc325 is offline
Wannabe Coder
 
Join Date: Sep 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
THank you very much everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Record Clicks cyberfolli PHP 0 09-26-06 06:14 PM
limit the inserted record hubby ASP 1 09-08-06 11:07 AM
scrolling in record pallabmondal123 PHP 0 03-27-06 07:01 AM
Phase Previous and Next Record pallabmondal123 PHP 1 03-03-06 01:55 AM
1 record missing sjems PHP 8 04-26-05 04:09 AM


All times are GMT -5. The time now is 04:56 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.