Jump to content

Form posting help please, checkbox inputs ******SOLVED******


skatermike21988

Recommended Posts

Ok I have a mysql query with a loop so it will pull all necasary data out, i need to display a checkboc next to it with a submit button on the bottom of the table to where the selected data will be deleted, kinda like a hotmail mailbox, and the checkbox's value is the id that will submit to a page to parse the data.

this is what i have:
[code]
$delete=$_GET[delete];
//FIRST CHECK IF DELETING SO IT DOES NOT SHOW BELOW
if($delete=='invite'){
$sql = "delete from event_invites where event_id=$_POST[eventid] && user_id='$id'";
mysql_query($sql);
echo"<font color=red><center>Events Deleted";

}




if($mail=='invites')) {
echo"<form name=delete action='?delete=invite&mail=invites&sid=$sid' method='post'>";
$sql1 = mysql_query("SELECT * FROM `event_invites` WHERE user_id ='$id' LIMIT $from, $max_results");
while($row1 = mysql_fetch_array($sql1)){
$eventid=$row1[event_id];

echo"<tr><td><center><input type='checkbox' name='eventid' value='$eventid'>";
}
echo"<input type=submit name='deleteinvite' value='Delete Selected'>";
}

[/code]

All help appreciated
Link to comment
Share on other sites

Just had a quick look and for a start you have a $_POST directly in your query. You should really set this value first as a normal variable then enter it along with ' ' or convert first to an int as you will normally find that mysql might think the value is a var.

I would have a better look but alot of the html go in the way. If you can do a more simple code with just the php and basic html it would be easyier to look at as i don't know long.

I take it that it is a list of check box each with an number value that if the user checks and posts this value will be deleted.

Just looking at your code I would also add after the mysql_query($sql) or die(mysql_error());

I think you have an error in your sql because of the post and no quotes around that value. This should let you know as it will echo it to the screen.
Link to comment
Share on other sites

Ok here is a revised version of my code
[code]

$delete=$_GET[delete];

//FIRST CHECK IF DELETING SO IT DOES NOT SHOW BELOW

if($delete=='invite'){
$eventid=$_POST[eventid]
$sql = "delete from event_invites where event_id='$eventid' && user_id='$id'";
mysql_query($sql);


//DISPLAY THAT THE EVENT HAS BEEN DELETED

}




if($mail=='invites')) {


//START THE FORM


$sql1 = mysql_query("SELECT * FROM `event_invites` WHERE user_id ='$id' LIMIT $from, $max_results");
while($row1 = mysql_fetch_array($sql1)){
$eventid=$row1[event_id];

//CHECKBOX WILL DISPLAY HERE


}

//WITH SUBMIT BUTTON TO FOLLOW

}
[/code]

Hope that's a little better
Link to comment
Share on other sites

Thanks, i have it working now, here is the code i used:

[code]


if($delete=='invite'){
//remove junk requests
$posted=$_POST[eventid];
foreach ($posted as $posted) {
$sql = "delete from event_invites where event_id='$posted' && user_id='$id'";
mysql_query($sql) or die(mysql_error());
}
echo"<font color=red><center>Events Deleted</font>";

}




echo"<tr><td><center><input type='checkbox' name='eventid[]' value='$eventid'>";
[/code]

I appreciate the help guys
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.