Re: [PHP] Help with PHP processing form checkboxes needed :-(

2009-05-18 Thread chris_payne

Hi there,

Thanks to everyone who replied about the checkboxes, I must have had 
brainrott or something as the answer was so simple - just delete the entries 
for the items on the page and put them back in again.  Simple and works like 
a charm :-)


Regards

Chris Payne

- Original Message - 
From: "kranthi" 

To: "Michael A. Peters" 
Cc: ; 
Sent: Monday, May 18, 2009 7:48 PM
Subject: Re: [PHP] Help with PHP processing form checkboxes needed :-(



1. every time the form is submitted.. generate the list of all the
check boxes which are checked and overwrite the previous value in the
database.

2. get the list of all entries from the database see if the
corresponding check box is checked.. if so leave it as it is, if not
remove it...

this depends much on the database implementation. obviously this is a
one to many relationship.
if i use a single field with coma separated values i prefer the former
if i use a different table to store the relationships(one relation per
row) i prefer the later.

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




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



Re: [PHP] Help with PHP processing form checkboxes needed :-(

2009-05-18 Thread Michael A. Peters

Paul M Foster wrote:



When you say "it sends its id", what do you mean? You're not talking
about the ID attribute of the checkbox tag, are you?

The way I handle something like this is to give the checkbox tag a
"value" attribute. Like:



Each page has to be a form if you do this. When you check the form, look
for $_POST['mixer'] == 'ordered_mixer'. If that relation is true, the
user left the box checked. If it's not true, the user unchecked the box.

Don't hold me to this. Do an experiment and see if that doesn't work.
I'm operating from memory, and I could be wrong.

Paul



That's basically what I do except I don't care what value is sent so I 
set the value to 1, a value won't be set if isn't checked, so I just 
check to see if the _POST['whatever'] is set or not.


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



Re: [PHP] Help with PHP processing form checkboxes needed :-(

2009-05-18 Thread Paul M Foster
On Mon, May 18, 2009 at 06:51:32PM -0700, chris_pa...@danmangames.com wrote:

> Hi everyone,
>
> I'm having a major problem.  I have an order system that allows you to add
> items with a checkbox, that works fine.  If you add an item and go back to
> the product listing the items that are in your cart show up as checked on
> the products listing forms to make it easier to see what you have in your
> cart.
>
> My problem comes here:
>
> I have been asked that if you have items in your cart and people are
> browsing your products, when they see it checked (Because they added it
> earlier) - well, basically they want to be able to uncheck it from there 
> and
> delete it from the database, how the heck can I do this?  When you check a
> box it's easy as it sends it's id but if you don't check one it doesn't 
> send
> any data or am I missing something?

When you say "it sends its id", what do you mean? You're not talking
about the ID attribute of the checkbox tag, are you?

The way I handle something like this is to give the checkbox tag a
"value" attribute. Like:



Each page has to be a form if you do this. When you check the form, look
for $_POST['mixer'] == 'ordered_mixer'. If that relation is true, the
user left the box checked. If it's not true, the user unchecked the box.

Don't hold me to this. Do an experiment and see if that doesn't work.
I'm operating from memory, and I could be wrong.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Help with PHP processing form checkboxes needed :-(

2009-05-18 Thread Michael A. Peters

kranthi wrote:



this depends much on the database implementation. obviously this is a
one to many relationship.


Probably easiest to do in the session database.
You can store the session fields in an external database if you want the 
shopping cart to persist over multiple sessions.


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



Re: [PHP] Help with PHP processing form checkboxes needed :-(

2009-05-18 Thread kranthi
1. every time the form is submitted.. generate the list of all the
check boxes which are checked and overwrite the previous value in the
database.

2. get the list of all entries from the database see if the
corresponding check box is checked.. if so leave it as it is, if not
remove it...

this depends much on the database implementation. obviously this is a
one to many relationship.
if i use a single field with coma separated values i prefer the former
if i use a different table to store the relationships(one relation per
row) i prefer the later.

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



Re: [PHP] Help with PHP processing form checkboxes needed :-(

2009-05-18 Thread Michael A. Peters

chris_pa...@danmangames.com wrote:

Hi everyone,

I'm having a major problem.  I have an order system that allows you to 
add items with a checkbox, that works fine.  If you add an item and go 
back to the product listing the items that are in your cart show up as 
checked on the products listing forms to make it easier to see what you 
have in your cart.


My problem comes here:

I have been asked that if you have items in your cart and people are 
browsing your products, when they see it checked (Because they added it 
earlier) - well, basically they want to be able to uncheck it from there 
and delete it from the database, how the heck can I do this?  When you 
check a box it's easy as it sends it's id but if you don't check one it 
doesn't send any data or am I missing something?


Please be gentle with me as this is confusing the heck out of me :-)


if (isset($_POST['someitem'])) {
   $someitem_checked = true;
   } else {
   $someitem_checked = false;
   }



Regards

Chris




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



[PHP] Help with PHP processing form checkboxes needed :-(

2009-05-18 Thread chris_payne

Hi everyone,

I'm having a major problem.  I have an order system that allows you to add 
items with a checkbox, that works fine.  If you add an item and go back to 
the product listing the items that are in your cart show up as checked on 
the products listing forms to make it easier to see what you have in your 
cart.


My problem comes here:

I have been asked that if you have items in your cart and people are 
browsing your products, when they see it checked (Because they added it 
earlier) - well, basically they want to be able to uncheck it from there and 
delete it from the database, how the heck can I do this?  When you check a 
box it's easy as it sends it's id but if you don't check one it doesn't send 
any data or am I missing something?


Please be gentle with me as this is confusing the heck out of me :-)

Regards

Chris 



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