View Full Version : Need tutorial
On file:///C:/DOCUME%7E1/Ryan-/LOCALS%7E1/Temp/moz-screenshot.jpg file:///C:/DOCUME%7E1/Ryan-/LOCALS%7E1/Temp/moz-screenshot-1.jpg how to delete several rows on a mysql database using checkboxes, so you check loads of differant rows and it deletes them all.
Ty
:Edzy
31-05-2007, 09:52 AM
On file:///C:/DOCUME%7E1/Ryan-/LOCALS%7E1/Temp/moz-screenshot.jpg file:///C:/DOCUME%7E1/Ryan-/LOCALS%7E1/Temp/moz-screenshot-1.jpg how to delete several rows on a mysql database using checkboxes, so you check loads of differant rows and it deletes them all.
Ty
lol we cant see files on your pc :rolleyes:
www.uploadz.co.uk (http://www.uploadz.co.uk) it.
there ain't a screeny there i dont have a clue why thats there..
Just read the text :)
Drompo
31-05-2007, 10:18 AM
<?php
$host = "localhost";
$username = "username";
$password = "password";
$database = "database";
$connect = mysql_connect($host, $username, $password);
$select_db = mysql_select_db($database, $connect);
if($_GET["action"] == "delete") {
$id = $_POST["id"];
mysql_query("DELETE FROM `table` WHERE `id` = '$id'") or die (mysql_error());
echo "$id Deleted";
} else {
$query = mysql_query("SELECT * FROM `table`") or die (mysql_error());
while ($view = mysql_fetch_array($query)) {
?>
<input name="checkbox" type="checkbox" value="<?php echo "{$view["id"]}"; ?>" /><?php echo "{$view["text"]}"; ?>
<?php
}
?>
<input type="submit" value="Delete">
<?php
}
?>
Something like that, Have a Play
Im not really sure thats what im looking for
Basically says theres a page while'ing out a database of users, theres 5 users in the database it looks like this:
Bob
Ryan
Mark
Tom
Dan
Basically i want each name to have a checkbox next to it, and when you click "Delete Checked" button it goes to a page then deletes all the people that were checked from the database.
Mr Macro
31-05-2007, 10:34 AM
So your looking for a script not a tutorial.
Mr Macro
31-05-2007, 10:39 AM
<?php
$host = "localhost";
$username = "username";
$password = "password";
$database = "database";
$connect = mysql_connect($host, $username, $password);
$select_db = mysql_select_db($database, $connect);
if($_GET["action"] == "delete") {
$id = $_POST["id"];
mysql_query("DELETE FROM `table` WHERE `id` = '$id'") or die (mysql_error());
echo "$id Deleted";
} else {
$query = mysql_query("SELECT * FROM `table`") or die (mysql_error());
while ($view = mysql_fetch_array($query)) {
?>
<input name="checkbox" type="checkbox" value="<?php echo "{$view["id"]}"; ?>" /><?php echo "{$view["text"]}"; ?>
<?php
}
?>
<input type="submit" value="Delete">
<?php
}
?>Something like that, Have a Play
There you go.
:Edzy
31-05-2007, 10:46 AM
There you go.
lolz :P
Drompo
31-05-2007, 11:26 AM
When i post scripts people seem to be oblivious to them
Thats not what i want, hence i was posting again, Mr.SmartAss.
Thats not what i want, hence i was posting again, Mr.SmartAss.
That is what you want seems as it works with what you described, Mr.SmartIdiot
Florx
31-05-2007, 11:53 AM
Dont get grumpy.
nobody will help you if you get grumpy.
That is what you want seems as it works with what you described, Mr.SmartIdiot
I think I know what i want, ty.
I think I know what i want, ty.
Im not really sure thats what im looking for
Basically says theres a page while'ing out a database of users, theres 5 users in the database it looks like this:
Bob
Ryan
Mark
Tom
Dan
Reinas script displays the users with a checkbox them beside and when you press delete it deletes the users
Be grateful or leave.
Mr Macro
31-05-2007, 11:57 AM
how to delete several rows on a mysql database using checkboxes, so you check loads of differant rows and it deletes them all.
Ty
That script Reina posted shows you how to do it.
Florx
31-05-2007, 12:01 PM
ditto - that script is what you explained you wanted. if you want something different EXPLAIN IT AGAIN AND BETTER.
Other than that go to another forum.
That has one box on it.. =/
Mr Macro
31-05-2007, 12:03 PM
You put the form bit befor the part where it echos out the usernames in the loop.So it echos out the username and the checkbox for each user.
Mr Macro
31-05-2007, 12:07 PM
What ?
it echos out the entrys in the database yah, but when i tick and click delete it doesnt delete.
Mr Macro
31-05-2007, 12:13 PM
You need to edit the code... that code was a sample, you need to edit it for your own needs, or better yet, learn what it does and rewrite it for your needs.
Sygon..
31-05-2007, 12:28 PM
Use an array > loop it, stop the loop from continusly looping.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.