skatermike21988 Posted September 26, 2006 Share Posted September 26, 2006 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 BELOWif($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 Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 26, 2006 Author Share Posted September 26, 2006 anything, this has been bothering the heck outa me for hours, can't even sleep because of it... Quote Link to comment Share on other sites More sharing options...
steveclondon Posted September 26, 2006 Share Posted September 26, 2006 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. Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 26, 2006 Author Share Posted September 26, 2006 Ok here is a revised version of my code[code]$delete=$_GET[delete];//FIRST CHECK IF DELETING SO IT DOES NOT SHOW BELOWif($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 Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 26, 2006 Author Share Posted September 26, 2006 and i added the or die(mysql_error()); and it returns nothing. Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 26, 2006 Author Share Posted September 26, 2006 Basicly what i need is to have a check box with the same name, like a radio button would but has different values, reason being i am not using a radio button is because only one can be selected, checkbox's can have multiple but the conflict is that they all have the same name Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 26, 2006 Author Share Posted September 26, 2006 Anything??? Quote Link to comment Share on other sites More sharing options...
warewolfe Posted September 26, 2006 Share Posted September 26, 2006 hej Perhaps if you want multiple values to go to the same name then that name should be an array. Eg checkboxName[]WW Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 26, 2006 Author Share Posted September 26, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.