RE: [PHP] Adjust two or more mysql rows ?
| From: | Ed Lazor | Date: | Wed, 11 Aug 2004 18:28:06 +0000 |
| Subject: | RE: [PHP] Adjust two or more mysql rows ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-193492@lists.php.net to get a copy of this message | ||
I don't think you can have a single mysql query do what you're wanting.
Break it into mutiple queries.
> -----Original Message-----
> Hi List,
>
> I have a qty posted via a form field, lets say 46.
>
> In my mysql table I have two rows which I want to reduce their qty fields.
>
> 1 row has a qty of say 13 and the second has a qty of 50, making 63 in
> total.
>
> So I would like to say something like if $_POST[qty] is greater than row
> 1's
> qty then update row[qty] = 0, then minus what was the row qty, 13 , from
> $_POST[qty] to new var say $newqty = $_POST[qty]-$row[qty], this leaves
> 37.
>
> Then from the 2nd row take 37 from its qty of 50 leaving 13. End result
> being row 1's qty field = 0 and row 2's qty field = 13.
>
> I hope this is not as clear as mud and if you need further clarity to be
> able to advise me then I will be happy to correspond.
>
> I thank you fully in advance for any help, logic pointers or nuggets of
> wisdom.
>
> Dave Carrera
>
>
> --
> UK Web Hosting @ http://www.ephgroup.com
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.736 / Virus Database: 490 - Release Date: 09/08/2004
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php