Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Select rows to delete with a checkbox
I've been trying to search for a decent and clear source of help
for something as simple as deleting rows with checkboxes. Please, can
someone give me a helping hand here?

I have this kind of "code" already, actually the delete
page. I'll try to simplify it as much as I can.

pages_row[page_id"] is a 10 digit randomly generated
id received from database talbe "pages"

<?php
if (!submit) // if the delete command has been submitted
(button pressed)
{
?>
<table cellpadding="4" cellspacing="0"
border="0">
<form action="index.php?admin=pages&sub=delpage"
method="POST">
<?php while(pages_row =
mysql_fetch_array(pages_result)) { ?>
<tr>
<td>
<input type="checkbox" name="del[]"
value="<?php echo pages_row["page_id"];
?>"><?php echo pages_row["page_title"];
?>
</td>
</tr>
<?php } ?> // to end the while-loop
</table>
<input type="submit" name="submit"
value="Delete selected">
<?php } // close the submit check

else // if the page has been submitted, delete all the checked
page_id's

Hah, I need a code here. I've tried quite a many examples but
they were all.. well.. any help, please?

} // end the delete loop
?>


:: Be patient with me, I'm new to PHP and MySQL :: :)

----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums



Report this thread to moderator Post Follow-up to this message
Old Post
nezbie
08-18-04 08:57 PM


Re: Select rows to delete with a checkbox
--------
# if delete selected chosen

{
ids_to_delete = join(',' ,
_POST['del']);
mysql_query("DELETE FROM pages WHERE
page_id IN (ids_to_delete))";
}
--------

Suppose 1, 3 and 5 are selected.  These are in the array
_POST['del']. The first line create a string
"1,3,5". The next line deletes ids in that list.

hth

Barand

http://members.aol.com/barryaandrew...agridguide.html easy
data tables - and more

----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums



Report this thread to moderator Post Follow-up to this message
Old Post
Barand
08-18-04 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:45 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.