How-to select items from a list

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm trying to do something and I'm sure there is a good technique for
it, but I just can't figure it out.

I have some member records in a database. I want to display a list of
them, and have a checkbox next to each member. One can then click in
the checkboxes for one or more members and the next page should then
take action on the selected members.

I know how to get the members from the database, I know how to create
the form to display each member with a checkbox next to their name.

What I can't figure out is a good method to name/identify the
checkboxes so that the values passed to the next URL can be
programatically processed in a loop.

I'll try and demonstrate:

<form action="sendsms.php">
<!-- I'm outputting this in a while loop -->
<td><input type=checkbox name=?? value=$mem_id></td>
<!-- end while loop -->
<input type="submit" value="Submit">

I assume that the $id (unique member id) would be a good value for the
checkbox to have, but I don't know what to name the checkbox so that
in the action URL I can loop through the values to process those

Thanks for any help.

Re: How-to select items from a list

Quoted text here. Click to load it
Quoted text here. Click to load it

I've made some progress with this (Google is good!), but I've got a
little problem I can't figure out. Is there somewhere that I can post
some php code to for people to look at and tell me what I'm doing
wrong?  Thanks!

I found some information that indicates that if the name of the
checkbok has square braces ([]) it should be able to get the data from
the $_POST variable with a statement like:


However, I come up with nothing in the resulting array.

I can post a sample program if anyone would tell me where and would be
willing to look at it.

Thanks again.

Re: How-to select items from a list

MikeB wrote:
Quoted text here. Click to load it

Just post it here.  If it's large, trim it down to a manageable size
that shows the problem.

But if you have:

<input type=checkbox name='sendid[]' value=$mem_id>

$_POST['sendid'] will be an array with one element for each checked
checkbox.  Unchecked boxes will not send their value.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: How-to select items from a list

Quoted text here. Click to load it

Finally figured this out. A really dumb (newbie?) mistake.

I was using "Get" as the method for the form, so that I could see the
parameters being passed in the URL. Obviously $_POST doesn't see those
parameters, but $_GET does.

So it's all fixed now.

Site Timeline