UPDATE a record in MYSQL DB with PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James

    UPDATE a record in MYSQL DB with PHP

    What is the best way to update a record in a MYSQL DB using a FORM and PHP
    ?

    Where ID = $ID !

    Any examples or URLS ?

    Thanks
  • Marcus

    #2
    Re: UPDATE a record in MYSQL DB with PHP

    James wrote:[color=blue]
    > What is the best way to update a record in a MYSQL DB using a FORM and PHP
    > ?
    >
    > Where ID = $ID !
    >
    > Any examples or URLS ?
    >
    > Thanks[/color]

    $query = " UPDATE table_name
    SET field = '$field'
    WHERE ID = '$ID'";
    $result = mysql_query($qu ery);

    Whatever you name your form element, put that variable name where $field
    is... the contents of the element will be directly accessible by this
    name once you POST if it is a textbox or list/menu, if you're using
    radio buttons you can test what the value attribute is, and if you're
    using checkboxes you can use isset() to see if it was checked.

    Marcus


    Comment

    Working...