[PHP] php and checkboxes.

2003-09-29 Thread Angelo Zanetti

Hi all

I have a table that is populated from a database which gets the IDs of the
records from a php array.Every row in the table has a checkbox next to the
actual record, what I want to do is to allow the user to select the records
they want to remove by clicking the checkbox(es) and then click a button to
submit the form.

so how do I remove these records? do I:

-do I do an array_diff and then just select the records that are remaining?

this to me seems the most logical.

tia

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



Re: [PHP] php and checkboxes.

2003-09-29 Thread Marek Kilimajer
Simple:
foreach($_POST['del_checkboxes'] as $id) {
$sql=delete from table where id='$id';
}
Checkboxes are created using
input  name=del_checkboxes value=?= $id ?
Angelo Zanetti wrote:

Hi all

I have a table that is populated from a database which gets the IDs of the
records from a php array.Every row in the table has a checkbox next to the
actual record, what I want to do is to allow the user to select the records
they want to remove by clicking the checkbox(es) and then click a button to
submit the form.
so how do I remove these records? do I:

-do I do an array_diff and then just select the records that are remaining?

this to me seems the most logical.

tia

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


RE: [PHP] php and checkboxes.

2003-09-29 Thread Angelo Zanetti

Hi Marek,

I dont actually want to delete the record from the database, perhaps I wasnt
very clear in my explanation, but I just need to remove that entry from the
table.

kinda like when deleting mail from your web email account like hotmail.


-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 1:36 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] php and checkboxes.


Simple:
foreach($_POST['del_checkboxes'] as $id) {
$sql=delete from table where id='$id';
}

Checkboxes are created using
input  name=del_checkboxes value=?= $id ?

Angelo Zanetti wrote:

 Hi all

 I have a table that is populated from a database which gets the IDs of the
 records from a php array.Every row in the table has a checkbox next to the
 actual record, what I want to do is to allow the user to select the
records
 they want to remove by clicking the checkbox(es) and then click a button
to
 submit the form.

 so how do I remove these records? do I:

 -do I do an array_diff and then just select the records that are
remaining?

 this to me seems the most logical.

 tia


--
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] php and checkboxes.

2003-09-29 Thread Eugene Lee
On Mon, Sep 29, 2003 at 01:43:08PM +0200, Angelo Zanetti wrote:
: 
: Marek Kilimajer suggested:
: 
:  Angelo Zanetti wrote:
:  
:   I have a table that is populated from a database which gets the
:   IDs of the records from a php array.Every row in the table has a
:   checkbox next to the actual record, what I want to do is to allow
:   the user to select the records they want to remove by clicking the
:   checkbox(es) and then click a button to submit the form.
:  
:   so how do I remove these records?
:  
:  Simple:
:  foreach($_POST['del_checkboxes'] as $id) {
:  $sql=delete from table where id='$id';
:  }
: 
: I dont actually want to delete the record from the database, perhaps I
: wasnt very clear in my explanation, but I just need to remove that
: entry from the table.

To remove a record is to delete a row.  Same thing.  When you say
entry, do you mean record or row?  Or do you mean something else?

If you want to change one or more columns of a row (this can also
be stated as one or more fields of a record), use the SQL command
UPDATE table SET col1=expr1,col1=expr2,... WHERE ID=id_expr.

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



Re: [PHP] php and checkboxes.

2003-09-29 Thread CPT John W. Holmes
From: Angelo Zanetti [EMAIL PROTECTED]

 I dont actually want to delete the record from the database, perhaps I
wasnt
 very clear in my explanation, but I just need to remove that entry from
the
 table.

 kinda like when deleting mail from your web email account like hotmail.

Same idea...

input type=checkbox name=remove[] value=xx

Where xx is the ID of that entry/row.

Then, to select whatever is in the table, minus whatever was selected...

$list = implode(',',$_POST['remove']);
$query = SELECT * FROM Table WHERE id NOT IN ($list);

If you want this list to propagate each time things are selected, then
you'll have to remember what's been selected using the session or hidden
elements.

---John Holmes...

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



[PHP] php and checkboxes

2003-09-23 Thread Angelo Zanetti
Hi all,

I have a table that gets populated from records of a DB. every row in the
table has a checkbox and the items desc. I want the user to select the items
they want and then they click on a link which registers the items they've
selected in a session variable. Firstly I am not sure if this can be done on
that same page or on the page to which the link calls. IE: if php can
determine which checkboxes have been selected. All the checkboxes are all
part of an array.

this is the way it should work:

1. the user selects the items they want
2. then clicks a link to another page
3. this page then displays what was selected
4. this info must be sent in a session variable.
5. must not use a submit button as I want the info to be saved in session
variable.

I hope that this makes sense.
TIA

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



Re: [PHP] php and checkboxes

2003-09-23 Thread Robert Cummings
On Tue, 2003-09-23 at 08:17, Angelo Zanetti wrote:
 Hi all,
 
 I have a table that gets populated from records of a DB. every row in the
 table has a checkbox and the items desc. I want the user to select the items
 they want and then they click on a link which registers the items they've
 selected in a session variable. Firstly I am not sure if this can be done on
 that same page or on the page to which the link calls. IE: if php can
 determine which checkboxes have been selected. All the checkboxes are all
 part of an array.
 
 this is the way it should work:
 
 1. the user selects the items they want
 2. then clicks a link to another page

Link can have javascript in it to either build a target URL or to submit
the form. I'd personally go for the form solution since the URL will be
ugly.

 3. this page then displays what was selected

Form submits to the same page in which it is presented.

 4. this info must be sent in a session variable.

Why? Set up the session variable using the data submitted by the form.

 5. must not use a submit button as I want the info to be saved in session
 variable.

Once again why? Sure I can see not using a submit button, but I don't
see how that relates to the info being saved in a session variable.

 
 I hope that this makes sense.

Somewhat :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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