RE: [PHP] Selecting what's for deletion

2002-12-27 Thread John W. Holmes
> Thanks John and Marek for your fast responses. I made the decision to
> opt for the "hidden" tag option. Now, I'll show you the part of my
code
> that hangs when trying to make what I intend it to do.
> 
> 
> 
> $query1 = "DELETE * FROM maracat WHERE catid = $catid";
> $result1 = mysql_query($query1) or die (mysql_errno());
> 
> $query2 = "DELETE * FROM marasubcat WHERE catid = $catid";
> $result2 = mysql_query($query2) or die (mysql_errno());
> 
> $query3 = "DELETE * FROM maraprod WHERE catid = $catid";
> $result3 = mysql_query($query3) or die (mysql_errno());
> 
> echo "Accion taken";
> echo "Back";
> 
> 
> 
> I know that it's very tedious to write 1 query for each action taking
> place, but I think this is easier for me to change in the future. Now,
> the page gets stuck when reaching this level and doesn't process what
I
> ordered... Any thoughts? Thanks in advance,

Do you get an errorno() or does it just not delete? It's better to echo
mysql_error() along with mysql_errno() in your die() statement.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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




RE: [PHP] Selecting what's for deletion

2002-12-27 Thread Cesar Aracena
Thanks John and Marek for your fast responses. I made the decision to
opt for the "hidden" tag option. Now, I'll show you the part of my code
that hangs when trying to make what I intend it to do.



$query1 = "DELETE * FROM maracat WHERE catid = $catid";
$result1 = mysql_query($query1) or die (mysql_errno());

$query2 = "DELETE * FROM marasubcat WHERE catid = $catid";
$result2 = mysql_query($query2) or die (mysql_errno());

$query3 = "DELETE * FROM maraprod WHERE catid = $catid";
$result3 = mysql_query($query3) or die (mysql_errno());

echo "Accion taken";
echo "Back";



I know that it's very tedious to write 1 query for each action taking
place, but I think this is easier for me to change in the future. Now,
the page gets stuck when reaching this level and doesn't process what I
ordered... Any thoughts? Thanks in advance,

Cesar L. Aracena
[EMAIL PROTECTED]
[EMAIL PROTECTED]
(0299) 156-356688
Neuquén (8300) Capital
Argentina


-Mensaje original-
De: John W. Holmes [mailto:[EMAIL PROTECTED]] 
Enviado el: jueves, 26 de diciembre de 2002 18:32
Para: 'Cesar Aracena'; [EMAIL PROTECTED]
Asunto: RE: [PHP] Selecting what's for deletion

> I'm making the administration part of a site which handles categories,
> sub categories and products. Inside the "Categories" part, there's a
> "List categories" button which gives a list of the categories and sub
> categories when pressed. Along with each category, there's a "Delete"
> button that, when pressed, it's supposed to delete that category from
> the DB. The problem here is that the lists is made dynamically using a
> FOR loop and is being placed inside a FORM so the action is handled
> through an ACTION="" tag.
> 
> Now, the ACTION tag points to a php file which deletes the desired row
> in the DB. The question is how to tell that php file (through GET or
> POST) which row to delete... My first shot was to name each "Delete"
or
> submit button inside form like "delcategory?catid=0001" but then the
> POST wasn't reading that...
> 
> Any thoughts? Thanks in advance,

You could use a bunch of forms, if you want to use a button. Since
you're using a while() loop, it wouldn't be a big deal...

While(fetching_from_db)
{
  
  
  Other data
  
  
}

Then the delete button on each row is for it's own form with a hidden
cat_id element that you can use to tell which row to delete.

Even better would be to use checkboxes, so you can delete multiple rows
at one. Name them 

And when it's submitted all of the checked boxes will be in
$_POST['delete'], so you can do this:

$delete_ids = implode(",",$_POST['delete']);
$query = "DELETE FROM table WHERE ID IN ($delete_ids)";

Add in your own validation, of course...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
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] Selecting what's for deletion

2002-12-27 Thread Marek Kilimajer
Make the "Delete" button a link with 
href="delcategory.php?catid=$catid", maybe with additional
information so you can redirect the browser back to where it has been 
(page #, parent category ...)

Cesar Aracena wrote:

Hi all,

I'm making the administration part of a site which handles categories,
sub categories and products. Inside the "Categories" part, there's a
"List categories" button which gives a list of the categories and sub
categories when pressed. Along with each category, there's a "Delete"
button that, when pressed, it's supposed to delete that category from
the DB. The problem here is that the lists is made dynamically using a
FOR loop and is being placed inside a FORM so the action is handled
through an ACTION="" tag.

Now, the ACTION tag points to a php file which deletes the desired row
in the DB. The question is how to tell that php file (through GET or
POST) which row to delete... My first shot was to name each "Delete" or
submit button inside form like "delcategory?catid=0001" but then the
POST wasn't reading that...

Any thoughts? Thanks in advance,

Cesar L. Aracena
[EMAIL PROTECTED]
[EMAIL PROTECTED]
(0299) 156-356688
Neuquén (8300) Capital
Argentina




 



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




RE: [PHP] Selecting what's for deletion

2002-12-26 Thread John W. Holmes
> I'm making the administration part of a site which handles categories,
> sub categories and products. Inside the "Categories" part, there's a
> "List categories" button which gives a list of the categories and sub
> categories when pressed. Along with each category, there's a "Delete"
> button that, when pressed, it's supposed to delete that category from
> the DB. The problem here is that the lists is made dynamically using a
> FOR loop and is being placed inside a FORM so the action is handled
> through an ACTION="" tag.
> 
> Now, the ACTION tag points to a php file which deletes the desired row
> in the DB. The question is how to tell that php file (through GET or
> POST) which row to delete... My first shot was to name each "Delete"
or
> submit button inside form like "delcategory?catid=0001" but then the
> POST wasn't reading that...
> 
> Any thoughts? Thanks in advance,

You could use a bunch of forms, if you want to use a button. Since
you're using a while() loop, it wouldn't be a big deal...

While(fetching_from_db)
{
  
  
  Other data
  
  
}

Then the delete button on each row is for it's own form with a hidden
cat_id element that you can use to tell which row to delete.

Even better would be to use checkboxes, so you can delete multiple rows
at one. Name them 

And when it's submitted all of the checked boxes will be in
$_POST['delete'], so you can do this:

$delete_ids = implode(",",$_POST['delete']);
$query = "DELETE FROM table WHERE ID IN ($delete_ids)";

Add in your own validation, of course...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



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




[PHP] Selecting what's for deletion

2002-12-26 Thread Cesar Aracena
Hi all,

I'm making the administration part of a site which handles categories,
sub categories and products. Inside the "Categories" part, there's a
"List categories" button which gives a list of the categories and sub
categories when pressed. Along with each category, there's a "Delete"
button that, when pressed, it's supposed to delete that category from
the DB. The problem here is that the lists is made dynamically using a
FOR loop and is being placed inside a FORM so the action is handled
through an ACTION="" tag.

Now, the ACTION tag points to a php file which deletes the desired row
in the DB. The question is how to tell that php file (through GET or
POST) which row to delete... My first shot was to name each "Delete" or
submit button inside form like "delcategory?catid=0001" but then the
POST wasn't reading that...

Any thoughts? Thanks in advance,

Cesar L. Aracena
[EMAIL PROTECTED]
[EMAIL PROTECTED]
(0299) 156-356688
Neuquén (8300) Capital
Argentina




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