I think programming just has a curse against me or something. I seem to get the weird errors, being that for this one my line of code that I feel is sure is causing the problem is exactly like all the examples I've been able to find on the net...so this is very frustrating.
I have two pages for Deleting the first is the selection page, lists the records with checkboxes next to them for the user to select and then a Delete button that passes to the second page. My first page shows up just fine.
So here's a line from my first page just so ya can see the name i'm using for the checkboxes..
echo "<input type='checkbox' name='id[".$i."] value='".$arrHorses['pk_horse_id']."'>";
The second page is suppose to get info for which records to delete from the first page and execute such a query. Then display the name of the records that were selected and say they were successfully deleted. Its connecting to the database just fine. But I'm getting a "not a valid result resource" error. arg, seems to be the error I always get.
Here's the important code for that page that I have thus far:
//store the Horse_ID passed from the previous page in a variable
$intDelete = $_POST['id'];
//Query to delete the record passed to it from the previous page
$strDeleteQuery = "DELETE FROM horses WHERE pk_horse_id = $intDelete";
//execute the query and save the result set in $rsHorse
$rsHorses = ConnectDatabase($strDeleteQuery);
for( $i = 0; $i < count($id); $i++)
{
//get a row of data and store it in $arrHorses
$arrHorses = mysql_fetch_array($rsHorses);
//echo records that were deleted
echo $id[$i];
echo "<br>";
//Give confirmation it was completed
echo "<h3>Successfully deleted selected record(s).</h3>";
echo "<br>";
}
Please help me figure out how to get it to delete the records.
I have a feeling this line:
$intDelete = $_POST['id'];
is the problem but I dont what else it should be named. I know thats not the exact same name as the checkboxes and I did try it with the same thing the checkboxes have and I get the same error.
So what do I name it, how do I get it to recognize what was checked on the previous page?
BTW, I know its connecting properly because the function ConnectDatabase has a line in it that echos "Successfully connected.." and I get that. It even display the other line in the code saying its been successfully deleted but inbetween the two success lines is the mysql error. Plus it is not displaying the names of the items checked.
Thanks!!!