Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-25 Thread Lewis Watson

- Original Message -
From: "Lewis Watson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 9:35 AM
Subject: [PHP-DB] Checkboxes to gather rows to delete


> I have a mysql database with a table using one column as a primary key.
> (rowID). On a php page I use a query to  list all of the rows of the
table
> and have a checkbox beside each  row that should be used to check if you
> would like to delete this row. Can someone give me an example using post
> to pull the boxes that need to be deleted.
> Thanks!
> Lewis



I appreciate everyones help. Below what I ended up with to actually delete
the checked boxes.
Lewis

// Deletes specified rows by teacherID.
if(isset($delete_teacher) && isset($deleteID)) {

while (list($key, $num)= each($_POST[deleteID])){

$delete_query = mysql_query("delete from
teacher where teacherID = $num");
print $delete_query;
print "";
}
}

//Checkbox and Submit lines...
 print "";

 print "";


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



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
I think the problem is that I need to put the array into a comma delimited
group
Lewis

- Original Message -
From: "John W. Holmes" <[EMAIL PROTECTED]>
To: "'Lewis Watson'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 11:09 AM
Subject: RE: [PHP-DB] Checkboxes to gather rows to delete


> > Hi there,
> > I have double checked the column namesIts giving me a Warning: Bad
> > arguments to implode() error
> > Thanks.
> > Lewis
>
> What's the code you're using? Are you sure $deleteID is an array at the
> point you call implode()? Are you sure it's available in the current
> scope at the point you call implode()?
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
> >
> > - Original Message -
> > From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> > To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > Sent: Monday, February 24, 2003 10:36 AM
> > Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
> >
> >
> > > > Thanks. The below code returns each ID in an array like so...
> > > > Array ( [0] =>101 [1] => 201 ). Thanks for the help!
> > > > Lewis
> > > >
> > > > $teacherID = $_POST[teacherID];
> > > > $deleteID = $_POST[deleteID];
> > > >
> > > > if(isset($delete_teacher)) {
> > > >   This is where I should loop through checking for the chosen
> ones
> > to
> > > > delete.
> > >
> > > $query = "DELETE FROM table WHERE teacherID IN (" .
> > implode(',',$deleteID) .
> > > ")";
> > > mysql_query($query);
> > >
> > > > }
> > > >
> > > > 
> > > >  print " > > > value=\"$row[teacherID]\">";
> > > >  print " value=\"Delete
> > the
> > > > Checked Teachers\">";
> > >
> > > Make sure the column names are correct, but that's it.
> > >
> > > ---John Holmes...
> > >
> > >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
Hi there,
I have double checked the column namesIts giving me a Warning: Bad
arguments to implode() error
Thanks.
Lewis

- Original Message -
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 10:36 AM
Subject: Re: [PHP-DB] Checkboxes to gather rows to delete


> > Thanks. The below code returns each ID in an array like so...
> > Array ( [0] =>101 [1] => 201 ). Thanks for the help!
> > Lewis
> >
> > $teacherID = $_POST[teacherID];
> > $deleteID = $_POST[deleteID];
> >
> > if(isset($delete_teacher)) {
> >   This is where I should loop through checking for the chosen ones
to
> > delete.
>
> $query = "DELETE FROM table WHERE teacherID IN (" .
implode(',',$deleteID) .
> ")";
> mysql_query($query);
>
> > }
> >
> > 
> >  print " > value=\"$row[teacherID]\">";
> >  print " > Checked Teachers\">";
>
> Make sure the column names are correct, but that's it.
>
> ---John Holmes...
>
>


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



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
Thanks. The below code returns each ID in an array like so...
Array ( [0] =>101 [1] => 201 ). Thanks for the help!
Lewis

$teacherID = $_POST[teacherID];
$deleteID = $_POST[deleteID];

if(isset($delete_teacher)) {
  This is where I should loop through checking for the chosen ones to
delete.

}


 print "";
 print "";


- Original Message -
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 10:21 AM
Subject: Re: [PHP-DB] Checkboxes to gather rows to delete


> > Thats just it. I am just not sure what to do with the array before my
> > "delete from" query now that I have it :-)
> > Thanks...
> > Lewis
>
> You don't have to do anything with it, just throw it into the line that
I
> gave you. Show the code you have now and someone can help you put it all
> together.
>
> ---John Holmes...
>
> > - Original Message -
> > From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> > To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> > Sent: Monday, February 24, 2003 10:13 AM
> > Subject: Re: [PHP-DB] Checkboxes to gather rows to delete
> >
> >
> > > > I appreciate all of the quick replies. I do have globals off.
> > Currently, I
> > > > have the values for each ID being returned in a array Array
( [0]
> > =>
> > > > 101 [1] => 201 )  where 101 and 201 were the id's of the rows I
> > checked. I
> > > > have to say I like the way of doing it that Mathieu has shown
using
> > the
> > > > explode function.
> > > > Thanks again.
> > > > Lewis
> > >
> > > You already have an array of IDs you want to delete. Explode is for
> > making
> > > arrays, so what would you use it on? That doesn't make sense.
> > >
> > > $query = "DELETE FROM table WHERE rowID IN (" .
> > > implode(',',$_POST['id_array']) . ")";
> > >
> > > is the most efficient, easiest solution, but use whatever you
> > understand.
> > >
> > > ---John Holmes...
> > >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
Thats just it. I am just not sure what to do with the array before my
"delete from" query now that I have it :-)
Thanks...
Lewis


- Original Message -
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
To: "Lewis Watson" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 10:13 AM
Subject: Re: [PHP-DB] Checkboxes to gather rows to delete


> > I appreciate all of the quick replies. I do have globals off.
Currently, I
> > have the values for each ID being returned in a array Array ( [0]
=>
> > 101 [1] => 201 )  where 101 and 201 were the id's of the rows I
checked. I
> > have to say I like the way of doing it that Mathieu has shown using
the
> > explode function.
> > Thanks again.
> > Lewis
>
> You already have an array of IDs you want to delete. Explode is for
making
> arrays, so what would you use it on? That doesn't make sense.
>
> $query = "DELETE FROM table WHERE rowID IN (" .
> implode(',',$_POST['id_array']) . ")";
>
> is the most efficient, easiest solution, but use whatever you
understand.
>
> ---John Holmes...
>


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



Re: [PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
I appreciate all of the quick replies. I do have globals off. Currently, I
have the values for each ID being returned in a array Array ( [0] =>
101 [1] => 201 )  where 101 and 201 were the id's of the rows I checked. I
have to say I like the way of doing it that Mathieu has shown using the
explode function.
Thanks again.
Lewis


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



[PHP-DB] Checkboxes to gather rows to delete

2003-02-24 Thread Lewis Watson
I have a mysql database with a table using one column as a primary key.
(rowID). On a php page I use a query to  list all of the rows of the table
and have a checkbox beside each  row that should be used to check if you
would like to delete this row. Can someone give me an example using post
to pull the boxes that need to be deleted.
Thanks!
Lewis



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