Thread: PHP4 and UPDATE

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    13
    Rep Power
    0
    Scenario.

    I have a form that has these fields:
    source
    post
    by
    title
    category
    date
    description

    now, each of these corresponds to a column in a table.

    now, I have gotten it to where I can print out the same form and set theinit var's to be the contents of the corresponding columns, but now lets say someone wants to update the source field, what is the query I need to use to do this?

    I am pretty sure its UPDATE, but I dont know the syntax, and the doc's were a little confusing.

    any help would be greatly appreciated....
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    You could use update. The syntax is:

    update tablename set fieldname=somevalue,otherfieldname=othervalue where something=something

    However, for this situation I would recommend using replace. Replace will work if you have some unique index in your table (usually your primary key).

    Replace uses the same syntax as insert (except you use 'replace' instead of 'insert') but if a unique value defined already exists, it will replace the values for the record with the new values defined. If none of the values match an already existing unique index, a new record is created.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    13
    Rep Power
    0
    how do I sinle out a solitary entry?
    how does it know which row to update?

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rod k:
    You could use update. The syntax is:

    update tablename set fieldname=somevalue,otherfieldname=othervalue where something=something

    However, for this situation I would recommend using replace. Replace will work if you have some unique index in your table (usually your primary key).

    Replace uses the same syntax as insert (except you use 'replace' instead of 'insert') but if a unique value defined already exists, it will replace the values for the record with the new values defined. If none of the values match an already existing unique index, a new record is created.
    [/quote]

  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    13
    Rep Power
    0
    lol, nm, I shortly removed my head from my rear end and figured it out. Thank you VERY much

Similar Threads

  1. Replies: 348
    Last Post: December 6th, 2006, 09:30 AM
  2. Help needed with PHP4 sessions and arrays
    By mgnetuk in forum PHP Development
    Replies: 1
    Last Post: November 20th, 2003, 01:24 PM
  3. Maintaining PHP4 and PHP5
    By IWS Mike in forum PHP Development
    Replies: 1
    Last Post: July 27th, 2003, 11:57 AM
  4. PHP POP3 Auto E-mail Check / Forward
    By dave981 in forum PHP Development
    Replies: 17
    Last Post: July 15th, 2003, 07:40 PM

IMN logo majestic logo threadwatch logo seochat tools logo