Re: Update query
| From: | Tim Ward | Date: | Thu, 12 Dec 2002 09:06:39 +0000 |
| Subject: | Re: Update query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127966@lists.php.net to get a copy of this message | ||
The best way would be to design the table so that it had an
item_id field that was an auto-incremented integer and not
updateable. It shouldn't be too late to add such a field, then it
can be passed from the form as a hidden field (as I assume
you're currently doing with $oldItemCode).
Tim Ward
http://www.chessish.com
mailto:timward@chessish.com
----- Original Message -----
From: Steve Jackson <stephen.jackson@violasystems.com>
To: PHP General <php-general@lists.php.net>
Sent: Thursday, December 12, 2002 9:00 AM
Subject: [PHP] Update query
> How do you update MySQL in the following way?
> I have designed a form which has all the fields in the database
> available to edit based on a user query. The query is a field called
> $ItemCode.
>
> If the user wants to change that $ItemCode field how do I update it? In
> other words how do I use PHP to update the database row called $ItemCode
> with a new $ItemCode where $ItemCode is $ItemCode?
>
> Here is what I've tried and failed at!
> $oldItemCode = $ItemCode;
> $query = "update products
> set ItemCode='$newItemCode',
> ItemName ='$ItemName',
> catid = '$catid',
> price = '$price',
> description = '$description'
> shortdesc = '$shortdesc'
> where ItemCode='$oldItemCode'";
>
> Steve Jackson
> Web Developer
> Viola Systems Ltd.
> http://www.violasystems.com
> stephen.jackson@violasystems.com
> Mobile +358 50 343 5159
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>