Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2104 > unrolled thread
| Started by | Co <vonclausowitz@gmail.com> |
|---|---|
| First post | 2011-06-11 11:10 -0700 |
| Last post | 2011-06-11 17:12 -0400 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.php
delete multiple records code Co <vonclausowitz@gmail.com> - 2011-06-11 11:10 -0700
Re: delete multiple records code Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-11 14:55 -0400
Re: delete multiple records code Co <vonclausowitz@gmail.com> - 2011-06-11 11:59 -0700
Re: delete multiple records code Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-11 17:12 -0400
| From | Co <vonclausowitz@gmail.com> |
|---|---|
| Date | 2011-06-11 11:10 -0700 |
| Subject | delete multiple records code |
| Message-ID | <1406cccf-ad82-400a-8fcc-136e4ff7dd5a@f11g2000vbx.googlegroups.com> |
Hi All,
I have some code which should delete some records.
It is a bulletin board page with posts. I want to delete the posts of
which the checkbox has been checked.
echo '<form name="form" id="form" method="post">';
if (isset($_SESSION['idx'])) {
if($account_type == 'c') {
$outputList .= '<td width="10%" ><div class="name"
align="left"><input type="checkbox" name="delete" value="' . $id . '" /
></div></td>';
}
}
echo '</form>';
if (isset($_POST['bb_index']) && !empty($_POST['form'])) {
foreach($_POST['form'] as $id) {
// This is a loop with the var $id containing
// all items that were checked to be deleted
print 'Delete this $id';
}
}
if (isset($_SESSION['idx'])) {
if($account_type == 'c') {
echo '<a href="bb_index.php?post=delete"><img src="images/
Delete.png" border="0" width="30" height="30" /></a>';
}} ?>
My code doesn't print any records even when some are checked.
Marco
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2011-06-11 14:55 -0400 |
| Message-ID | <it0dmq$lru$1@dont-email.me> |
| In reply to | #2104 |
On 6/11/2011 2:10 PM, Co wrote:
> Hi All,
>
> I have some code which should delete some records.
> It is a bulletin board page with posts. I want to delete the posts of
> which the checkbox has been checked.
>
> echo '<form name="form" id="form" method="post">';
> if (isset($_SESSION['idx'])) {
> if($account_type == 'c') {
> $outputList .= '<td width="10%"><div class="name"
> align="left"><input type="checkbox" name="delete" value="' . $id . '" /
>> </div></td>';
> }
> }
>
> echo '</form>';
>
> if (isset($_POST['bb_index'])&& !empty($_POST['form'])) {
> foreach($_POST['form'] as $id) {
> // This is a loop with the var $id containing
> // all items that were checked to be deleted
> print 'Delete this $id';
>
> }
> }
>
>
> if (isset($_SESSION['idx'])) {
> if($account_type == 'c') {
> echo '<a href="bb_index.php?post=delete"><img src="images/
> Delete.png" border="0" width="30" height="30" /></a>';
> }} ?>
>
> My code doesn't print any records even when some are checked.
>
> Marco
To start with, what's in your $_POST variable?
Also, if you set the name of your checkbox to "delete", you will only
get one value in your $_POST variable. You can either give each
checkbox a unique name, or (preferably) use 'delete[]' - which will
provide an array of checked boxes in your $_POST variable.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Co <vonclausowitz@gmail.com> |
|---|---|
| Date | 2011-06-11 11:59 -0700 |
| Message-ID | <300546d8-366d-453a-8661-78beae160fa0@r2g2000vbj.googlegroups.com> |
| In reply to | #2108 |
On 11 jun, 20:55, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 6/11/2011 2:10 PM, Co wrote:
>
>
>
>
>
>
>
>
>
> > Hi All,
>
> > I have some code which should delete some records.
> > It is a bulletin board page with posts. I want to delete the posts of
> > which the checkbox has been checked.
>
> > echo '<form name="form" id="form" method="post">';
> > if (isset($_SESSION['idx'])) {
> > if($account_type == 'c') {
> > $outputList .= '<td width="10%"><div class="name"
> > align="left"><input type="checkbox" name="delete" value="' . $id . '" /
> >> </div></td>';
> > }
> > }
>
> > echo '</form>';
>
> > if (isset($_POST['bb_index'])&& !empty($_POST['form'])) {
> > foreach($_POST['form'] as $id) {
> > // This is a loop with the var $id containing
> > // all items that were checked to be deleted
> > print 'Delete this $id';
>
> > }
> > }
>
> > if (isset($_SESSION['idx'])) {
> > if($account_type == 'c') {
> > echo '<a href="bb_index.php?post=delete"><img src="images/
> > Delete.png" border="0" width="30" height="30" /></a>';
> > }} ?>
>
> > My code doesn't print any records even when some are checked.
>
> > Marco
>
> To start with, what's in your $_POST variable?
>
> Also, if you set the name of your checkbox to "delete", you will only
> get one value in your $_POST variable. You can either give each
> checkbox a unique name, or (preferably) use 'delete[]' - which will
> provide an array of checked boxes in your $_POST variable.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
Jerry,
What do you mean with the first question?
If I do it like this:
if (isset($_SESSION['idx'])) {
if($account_type == 'c') {
$outputList .= '<td width="10%" ><div class="name"
align="left"><input type="checkbox" name="checkbox[]" id="checkbox[]"
value="' . $id . '" /></div></td>';
}
}
How can I loop through the records later?
Marco
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2011-06-11 17:12 -0400 |
| Message-ID | <it0loj$75c$1@dont-email.me> |
| In reply to | #2109 |
On 6/11/2011 2:59 PM, Co wrote:
> On 11 jun, 20:55, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 6/11/2011 2:10 PM, Co wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> Hi All,
>>
>>> I have some code which should delete some records.
>>> It is a bulletin board page with posts. I want to delete the posts of
>>> which the checkbox has been checked.
>>
>>> echo '<form name="form" id="form" method="post">';
>>> if (isset($_SESSION['idx'])) {
>>> if($account_type == 'c') {
>>> $outputList .= '<td width="10%"><div class="name"
>>> align="left"><input type="checkbox" name="delete" value="' . $id . '" /
>>>> </div></td>';
>>> }
>>> }
>>
>>> echo '</form>';
>>
>>> if (isset($_POST['bb_index'])&& !empty($_POST['form'])) {
>>> foreach($_POST['form'] as $id) {
>>> // This is a loop with the var $id containing
>>> // all items that were checked to be deleted
>>> print 'Delete this $id';
>>
>>> }
>>> }
>>
>>> if (isset($_SESSION['idx'])) {
>>> if($account_type == 'c') {
>>> echo '<a href="bb_index.php?post=delete"><img src="images/
>>> Delete.png" border="0" width="30" height="30" /></a>';
>>> }} ?>
>>
>>> My code doesn't print any records even when some are checked.
>>
>>> Marco
>>
>> To start with, what's in your $_POST variable?
>>
>> Also, if you set the name of your checkbox to "delete", you will only
>> get one value in your $_POST variable. You can either give each
>> checkbox a unique name, or (preferably) use 'delete[]' - which will
>> provide an array of checked boxes in your $_POST variable.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> Jerry,
>
> What do you mean with the first question?
>
Just what I said. What's in $_POST when you get the results back?
print_r($_POST);
does wonders for debugging!
> If I do it like this:
>
> if (isset($_SESSION['idx'])) {
> if($account_type == 'c') {
> $outputList .= '<td width="10%"><div class="name"
> align="left"><input type="checkbox" name="checkbox[]" id="checkbox[]"
> value="' . $id . '" /></div></td>';
> }
> }
> How can I loop through the records later?
>
> Marco
You don't need the id - that's for DOM (and each id must be unique).
When you get the results back the choices (if any) will be in
$_POST['checkbox'], which will be an array. Again, print out the values
in $_POST so you can see them.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web