Help with php delete script!!!!?
-
I am trying to delete multiple records on a forum with check boxes, but the code is not working. It is saying it has successfully been deleted but it doesn't delete the posts. Please help, 10 points for the best answer. $check="SELECT * FROM posts WHERE category_id='".$cid."' AND ID= '".$tid."'"; $result= mysql_query($check) or die(mysql_error()); $rows= mysql_fetch_assoc($result); $post_id=$rows['ID']; <input name='checkbox[]' type='checkbox' value='$post_id' /> if(isset($_POST['delete'])){ $checkbox=$_POST['checkbox']; $count_ids = count($_POST['checkbox']); //counting how many checkboxes have been selected. for($i=0;$i<$count_ids;$i++){ $del_id=$checkbox[$i]; $sqldelete = "DELETE from posts WHERE ID = $del_id"; $res4= mysql_query($sqldelete); echo"You have succsesfully deleted the selected post"; } ID is the ID of the post that someone has done.
-
Answer:
You need to provide you're self some feed back I would add a conditional statement if($res4) { echo "You have successfully deleted the selected post"; } else { echo "failed"; // you can then start using mysql_error if you're on a development site } Just as a side note ALWAYS ESCAPE your input - regardless where it came from
Dan at Yahoo! Answers Visit the source
Related Q & A:
- how delete node in xml file using php?Best solution by Stack Overflow
- How can i delete the links that posted on my status?it bothers my im to frends.pls help me delete that?Best solution by Yahoo! Answers
- Can't delete name off messenger address list, error code 40402,need help pls?Best solution by Yahoo! Answers
- How to start creating a php script, that will be installed on many servers?Best solution by Stack Overflow
- Mouseover script help?
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.