Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Multiple Database Entry Deletion
Old 08-20-2004, 12:32 PM Multiple Database Entry Deletion
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
Hey Guys. I've got a prob with a little project. I'm making a small management system (insert, view, modify & delete). So far all has gone to plan and it's looking ok. Now, the problem I'm having at the moment is I'm trying to make the deletion side of it. It's ok if I only have one entry, but how would I go about multiple entries?

I'm using forms to drive the system. The person clicks the checkbox and then clicks the delete button. Then I want it to delete the selected records.

I've been on it for about 5 hours (including modify).

Please help me if you can.

- Wenslock
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-20-2004, 12:43 PM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Are you deleting entries from a table or entries from multiple tables?

Ibbo
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 08-20-2004, 12:58 PM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
Trades: 0
You do it just like a SELECT query, but use DELETE instead. Lets say you have a table that stores letters, and a field called 'bseen', that is a tinyint, and is set to 0 if the letter has not been seen, or a positive number if the letter has been seen. To delete all letters that have been seen, we just do;

mysql_query("DELETE FROM mail_table WHERE bseen>0", $db);

Just like a SELECT, but if we want to delete the whole field, we leave out the asterisk (*). To explain further; if I wanted to SELECT all the letters that have been seen, I would just do;

mysql_query("SELECT * FROM mail_table WHERE bseen>0",$db);
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources,
Please login or register to view this content. Registration is FREE
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Old 08-22-2004, 07:18 PM
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
Thanks webWoRRks. I'll give it a go tomorrow.

ibbo - single table. I've decided that the user has to select the table before deleting the entries.

I'm trying to make it as user friendly as possible for them. To be honest, it would be easier (for me anyway) to use PHP MyAdmin, but they want it this way...

Actually, I will make it so that they have to confirm their deletion too.

Thanks again.
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
Old 08-25-2004, 09:38 AM
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
OK, I'm getting fed up of this now. I feel like I'm 180 or something

<code>
if ($delete == yes)
{
if ($confirm == yes)
{
$local = localhost;
$usern = userm;
$passw = passw;
$dbname = db;

mysql_connect($local,$usern,$passw);
mysql_query="DELETE FROM $table WHERE id>$id",$dbname;


mysql_close();
}
}
</code>

That's the bit I'm having trouble with. I'm going on holiday at the end of the week, so I'm trying to get this pain in the *** thing out of the way before I do. Any ideas guys?

<- Me gone mad
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
Old 08-25-2004, 06:45 PM
ermau's Avatar
Experienced Talker

Latest Blog Post:
Chopper pwnage
Posts: 47
Name: Eric
Location: Florida
Trades: 0
Well for one it's not mysql_query="";

It's
PHP Code:
mysql_query("DELETE FROM $table WHERE id>$id"); 
However, if register_globals is set to on, I could delete everything in the database by typing in the URL yourscript.php?table=thetable&id=0

As long as I guess the table name right, it'd delete everything from it. Find other ways of putting in variables to your queries.
ermau is offline
Reply With Quote
View Public Profile
 
Old 08-26-2004, 05:53 AM
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
ermau - Thanks. I'll see what I can do with

Don't worry about the security. This is only a snippet of the PHP that's used. There's a username, password, etc. I've tried to be really careful with this one. ^_-

Thanks again.

Wenslock
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
Old 08-26-2004, 10:33 AM
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
Finally got it working! Thanks guys for your help.

doomo arigato gozaimasu!
(Thank you very much)
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Multiple Database Entry Deletion
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27707 seconds with 12 queries