CMellor Posted April 8, 2006 Share Posted April 8, 2006 Hey.I've made a tag board, and an ACP to delete/ban posts/users, but I can't for some reason get to be able to delete the selected posts when I click delete on the tag.Here's my code, it aint long.[code]<?php/* TAGS */if($do = "interactive_tag_board_tags"): ?><table width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="header">Tags</td> </tr> <tr> <td class="row1"> <table width="99%" cellspacing="0" cellpadding="0"> <tr> <td width="5%" align="center" class="header">ID</td> <td width="25%" align="center" class="header">Poster</td> <td width="55%" align="center" class="header">Tag</td> <td width="15%" align="center" class="header">Options</td> </tr> <?php $query = mysql_query("SELECT * FROM $dbname.tags ORDER BY id DESC"); while($row = mysql_fetch_array($query)) { ?> <tr> <td align="center" class="row2"><?=$row['id']?></td> <td align="center" class="row2"><?=$row['poster']?></td> <td class="row2"><?=$row['tag']?></td> <td align="center" class="row2"><input type="hidden" name="id" value="<?=$row['id']?>" /> <a href="?do=interactive_tag_board_tags&delete=<?=$row['id']?>"><img src="../img/delete.gif" /></a></td> </tr> <?php } ?> </table> </td> </tr></table><?php /* END TAGS */ endif; ?>[/code]Can anyone give me a quick code that let's me delete the tag I select? I put a hidden input in their, thinking maybe that could be used somehow.Would really appriciate the help, thanks a lot.Chris. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 8, 2006 Share Posted April 8, 2006 The comparison operator for equals is "==" not "=". You have used the "=" in your "if" statement, change it to a "==" and see if that helps.Ken Quote Link to comment Share on other sites More sharing options...
CMellor Posted April 8, 2006 Author Share Posted April 8, 2006 The actual code I posted isn't the problem, though thanks for pointing that error out. I just asked if someone could write a little bit of code to allow me to delete my selected tag. I know it's asking a bit, but I know it can be done with only a couple of line's of code.I did try this, but it said "delete" before I even did anything[code]if($_GET['delete'] == $row['id']) { $refresh = mysql_query("DELETE FROM $dbname.tags WHERE id = '".$row['id']."'"); if($refresh) { echo('deleted'); } }[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted April 8, 2006 Share Posted April 8, 2006 At start of your code[code]<?if($_GET['do'] == "interactive_tag_board_tags"): if (isset ($_GET['delete'])) { $delid = $_GET['delete']; mysql_query("DELETE FROM $dbname.tags WHERE id = '$delid' "); }?>[/code] Quote Link to comment Share on other sites More sharing options...
CMellor Posted April 9, 2006 Author Share Posted April 9, 2006 Thanks for the help but that didn't do anything. Here's what I have.[code]<?php/* TAGS */if($do == "interactive_tag_board_tags"): $query = mysql_query("SELECT * FROM $dbname.tags ORDER BY id DESC"); if(isset($_GET['delete'])) { mysql_query("DELETE FROM $dbnames.tags WHERE id = '".$_GET['delete']."'"); }?><table width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="header">Tags</td> </tr> <tr> <td class="row1"> <table width="99%" cellspacing="0" cellpadding="0"> <tr> <td width="5%" align="center" class="header">ID</td> <td width="25%" align="center" class="header">Poster</td> <td width="55%" align="center" class="header">Tag</td> <td width="15%" align="center" class="header">Options</td> </tr> <?php while($row = mysql_fetch_array($query)) { ?> <tr> <td align="center" class="row2"><?=$row['id']?></td> <td align="center" class="row2"><?=$row['poster']?></td> <td class="row2"><?=$row['tag']?></td> <td align="center" class="row2"><input type="hidden" name="id" value="<?=$row['id']?>" /> <a href="?do=interactive_tag_board_tags&delete=<?=$row['id']?>"><img src="../img/delete.gif" /></a></td> </tr> <?php } ?> </table> </td> </tr></table><?php /* END TAGS */ endif; ?>[/code]Nothing happens when I click delete. Quote Link to comment Share on other sites More sharing options...
Barand Posted April 9, 2006 Share Posted April 9, 2006 You are now querying the tags table before the deletion has been executed. Move it to after the delete query[code]if($do == "interactive_tag_board_tags"): if(isset($_GET['delete'])) { mysql_query("DELETE FROM $dbnames.tags WHERE id = '".$_GET['delete']."'"); } $query = mysql_query("SELECT * FROM $dbname.tags ORDER BY id DESC");?>[/code] 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.