PDA

View Full Version : Need tutorial



Spec
31-05-2007, 09:41 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

: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.

Spec
31-05-2007, 10:06 AM
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

Spec
31-05-2007, 10:31 AM
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.

Spec
31-05-2007, 10:37 AM
Anything will do

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

Spec
31-05-2007, 11:43 AM
Thats not what i want, hence i was posting again, Mr.SmartAss.

Blob
31-05-2007, 11:53 AM
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.

Spec
31-05-2007, 11:54 AM
That is what you want seems as it works with what you described, Mr.SmartIdiot
I think I know what i want, ty.

Blob
31-05-2007, 11:57 AM
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.

Spec
31-05-2007, 12:02 PM
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.

Spec
31-05-2007, 12:04 PM
But it doesnt.

Mr Macro
31-05-2007, 12:07 PM
What ?

Spec
31-05-2007, 12:08 PM
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.

Spec
31-05-2007, 12:21 PM
ive tryed

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!