Hi, sorry I am new here and also very new to PHP & MySQL. this is another script that is trying to do the same thing (deleting rows with checkbox)
<?php
include "connect.php";
$result = mysql_query("SELECT * FROM users");
if(isset($_POST['delete'])){
if(is_array($_POST['id'])){
echo '<pre>';
print_r($_POST);
echo '<pre>';
foreach($_POST['id'] as $id){
$query = "DELETE FROM users WHERE id=".$id;
mysql_query($query)or die(mysql_error());
echo "User Deleted";
}
}
}
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST">
<?
echo "<table border='0'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Location</th>
<th>Email</th>
<th>Website</th>
<th>userID</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['website'] . "</td>";
echo "<td>" . $row['userID'] . "</td>";
?> <td><input type="checkbox" name="id[]" value="<?php $row['id'] ?>" /></td> <?
echo "</tr>";
}
echo "</table>";
echo "<input type='submit' value='Delete Users' name='delete' />";
mysql_close($con);
?>
this gives me this error:
Array
(
[id] => Array
(
[0] =>
)
[delete] => Delete Users
)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
And the first script does not seem to do anything at all, no error or anything.