Dave Carrera wrote:

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 think you have a seriously flawed database structure. There is no "row 1" in a database, you know that, right?


Pretty sure you can do what you're after, though, you'll just have to involve about four different queries and some PHP magic in the middle...

--

John Holmes

php|architect - The magazine for PHP professionals - http://www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to