Hmm I think I understand what you want. Being able to select articles by clicking on a checkbox and then those selected will be deleted, right? First of all setup your form and checkboxes, making sure the names of the checkboxes are all the same but they have different values...
[HTML]
<form action="script.php" method="post">
<!-- ALL YOUR OTHER FORM DATA BEFORE -->
<input type="checkbox" name="checkboxes[]" value="1" />
<input type="checkbox" name="checkboxes[]" value="2" />
<!-- ALL OTHER FORM DATA AFTER -->
<input type="submit" name="submit" value="Submit" />
</form>
[/HTML]
Once that data has been submitted you will do something similar to the following.
[PHP]
<?php
/* Check if data has been submitted... */
if(isset($_POST))
{
/* Ensure at least one checkbox from the group was checked */
if(isset($_POST))
{
/* Loop through and do as you please! */
foreach($_POST as $box)
{
echo $box;
}
}
}
?>
[/PHP]
Of course replace the "echo $box;" code with your own database code
danielneriWP V.I.P.VPS - Virtual Prince of the Server
thank you soo much felix!!
will try the code out asap!
danielneriWP V.I.P.VPS - Virtual Prince of the Server
alright so heres what ive come up with so far:
the main deleting page
[PHP]<?php
?>[/PHP]
end
im not sure how to put the checkboxes into a php page, and dont know how to put the php mysql data into html
im using your processing script, never actually been able to use it! ^
|
|
anyways heres the slightly modified script, though i dont think it will work
process.php
[PHP]<?php
/* Check if data has been submitted... */
if(isset($_POST))
{
/* Ensure at least one checkbox from the group was checked */
if(isset($_POST))
{
/* Loop through and do as you please! */
foreach($_POST as $box)
{
$delete = mysql_query(DELETE $box FROM tutorial);
if (!$delete) {
die('Invalid query: ' . mysql_error());
mysql_query($delete)
else echo "Query Succesfully executed."
}
}
[/PHP]
end
thanks sooo much for your help again!!!
danielneriWP V.I.P.VPS - Virtual Prince of the Server
ok after alot of playing around i managed to come up with this:
deleting sript:
[PHP]<?php
include ("dbconnect.php");
$titleresult = mysql_query("SELECT * FROM tutorials") or die(mysql_error());
while($title = mysql_fetch_object($titleresult)) {
Oh yeah sorry I forgot to mention that you need to check if the current checkbox value is empty. Simply add this code below the foreach statement in the delete script.
if(empty($box))
{
// SIMPLY DO NOTHING
} else {
// EXECUTE OTHER CODE HERE
}
danielneriWP V.I.P.VPS - Virtual Prince of the Server
but like i said b4
it serves the purpose of properly displaying the data, but since all the rows are on 1 checkbox, process.php deletes EVERYTHING from the database.
I want to know how to select just one row and then display it with a checkbox in front of it, so on etc.
Comments
Please elaborate.
Submit your threads
Music Forum
My Web Entrepreneur Blog
VolumeBoost - Member Chosen Music News
i want to add a little admin panel addon to the script, where it adds new articles, and deletes existing articles.
i want to know how to delete CERTAIN articles using DELETE FROM
any ideas?
[HTML]
<form action="script.php" method="post">
<!-- ALL YOUR OTHER FORM DATA BEFORE -->
<input type="checkbox" name="checkboxes[]" value="1" />
<input type="checkbox" name="checkboxes[]" value="2" />
<!-- ALL OTHER FORM DATA AFTER -->
<input type="submit" name="submit" value="Submit" />
</form>
[/HTML]
Once that data has been submitted you will do something similar to the following.
[PHP]
<?php
/* Check if data has been submitted... */
if(isset($_POST))
{
/* Ensure at least one checkbox from the group was checked */
if(isset($_POST))
{
/* Loop through and do as you please! */
foreach($_POST as $box)
{
echo $box;
}
}
}
?>
[/PHP]
Of course replace the "echo $box;" code with your own database code
will try the code out asap!
the main deleting page
[PHP]<?php
include ("dbconnect.php");
$tresult = mysql_query("SELECT title, message FROM tutorials") or die(mysql_error());
while($titmess= mysql_fetch_row($tresult)) {
echo "<table border='1'>";
echo "<tr> <th>Title, Message</th>";
echo "<td align='left'>$titmess[0]</td>";
echo "<td>$titmess[1]</td>";
echo "</tr>";
echo "</table>";
}
?>[/PHP]
end
im not sure how to put the checkboxes into a php page, and dont know how to put the php mysql data into html
im using your processing script, never actually been able to use it! ^
|
|
anyways heres the slightly modified script, though i dont think it will work
process.php
[PHP]<?php
/* Check if data has been submitted... */
if(isset($_POST))
{
/* Ensure at least one checkbox from the group was checked */
if(isset($_POST))
{
/* Loop through and do as you please! */
foreach($_POST as $box)
{
$delete = mysql_query(DELETE $box FROM tutorial);
if (!$delete) {
die('Invalid query: ' . mysql_error());
mysql_query($delete)
else echo "Query Succesfully executed."
}
}
[/PHP]
end
thanks sooo much for your help again!!!
deleting sript:
[PHP]<?php
include ("dbconnect.php");
$titleresult = mysql_query("SELECT * FROM tutorials") or die(mysql_error());
while($title = mysql_fetch_object($titleresult)) {
?>
<html>
<head>
<title>VC Delete Script v0.1</title>
</head>
<body>
<form method="post" action="process.php">
<a><input type="checkbox" name="checkboxes[]" value="1"><?php
echo "Title: $title->title<br>\n";
?></a>
<a><?php
echo "Message: $title->message<br>\n";
?>
</a>
<?php
}
?>
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>[/PHP]
it serves the purpose of properly displaying the data, but since all the rows are on 1 checkbox, process.php deletes EVERYTHING from the database.
I want to know how to select just one row and then display it with a checkbox in front of it, so on etc.
any ideaS?
if(empty($box))
{
// SIMPLY DO NOTHING
} else {
// EXECUTE OTHER CODE HERE
}
could you give me a sample script?
thanks a million
How about talking to me on MSN or something dude? I'll show you something I have made and then you can tell me if thats what you are aiming for.