![]() |
Multiple Checkbox problems
What I'm trying to do is delete items in a mysql database that are displayed with a simple checkbox. Here is the form that is generated.
Code:
<form action="" method="post">Code:
if(isset($_POST['submit'])) { |
That code actually works perfectly for me. This is what I have:
php Code:
And the HTML... html4strict Code:
I can really only surmise that either the $_POST array is being overwritten, or that for whatever reason there are no items being posted, but I'm not sure why that would be. Is your code getting to that segment where you execute the SQL statements? |
Man, I've been going over this for hours .. still not working and I see absolutely nothing wrong. I'm pretty much to the point where I'll pay someone to fix this, it's getting out of hand.
|
I feel for you! I've been in similar situations where things defy all reason. Sadly though I'm off to bed any time soon ;-) Maybe you can post us a bit more of the code - considering it isn't too long. Or maybe a pastebin otherwise.
|
When the html is loaded, can you view source and see if $row['id'] is filling in the blank correctly in your checkbox form field?
Alan |
Quote:
|
Please, oh please, turn error reporting on (error_reporting(E_ALL)) when in debug mode. The problem is in the printing business:
PHP Code:
PHP Code:
|
Quote:
Code:
print "<div class=\"delete\"><input type=\"checkbox\" class=\"delete-checkbox\" value=\"{$row['id']}\" name=\"deletebox\" /></div>"; |
They keep telling you:
Code:
print "<div class=\"delete\"><input type=\"checkbox\" class=\"delete-checkbox\" value=\"{$row['id']}\" name=\"deletebox\" /></div>";Code:
print "<div class=\"delete\"><input type=\"checkbox\" class=\"delete-checkbox\" value=\"{$row['id']}\" name=\"deletebox[]\" /></div>"; |
I've got it at least to recognize the number of items being submitted, but it doesn't pass the values still. when I checked three boxes it ouput:
Code:
Array |
Are you submiting via a Ajax JavaScript POST call or GET .
Cause i have had trouble with values donīt being transfered in some cases because of the form element being laid out with the help of Table elements. Canīt remebmer right now wich Framework i used but it was: jQuery, Prototype, MooTools, or someone like that. Just a thought. /EyeDentify |
Nope, just doing a regular form submission.
|
Try using
var_dump rather than print_r because the former will be able to show us the types of the values (integer, string, etc) as well as their actual value (e.g, FALSE does not display anything with print_r). |
Try echoing the value out to the page and see if there is an id being shown to the browser.
|
using var_dump
Code:
var_dump($_POST)Gives me: Code:
array(2) { ["deletebox"]=> string(0) "" ["submit"]=> string(15) "delete messages" } |
Quote:
|
| All times are GMT. The time now is 06:21 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0