TeddyKiller Posted April 1, 2010 Share Posted April 1, 2010 This is more of an ajax topic, although people reply much quicker in this forum. So sorry if this is rather unacceptable. Anyway, I have a jquery delete, but it only deletes 1 div. The header is.. <?php if(isset($_GET['delete'])) { $query = 'DELETE FROM `horblewall` WHERE id = '.$_GET['delete']; $result = mysql_query($query,$link); } ?> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function() { $('a.delete').click(function(e) { e.preventDefault(); var parent = $(this).parent(); $.ajax({ type: 'get', url: 'main.php?sk=wall', data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''), beforeSend: function() { parent.animate({'backgroundColor':'#fff'},300); }, success: function() { parent.slideUp(300,function() { parent.remove(); }); } }); }); }); </script> The body is.. $query = mysql_query("SELECT * FROM `horblewall` ORDER BY `posted` desc"); while($r = mysql_fetch_array($query)){ $q = mysql_query("SELECT * FROM `users` WHERE `id`=".$r['user_id'].""); $rw = mysql_fetch_array($q); echo ' <div style="border-bottom:1px solid #e11919;" class="record" id="record-'.$r['id'].'"> <div style="text-align:left; min-height:90px;"> <div style="float:right; width:105px;">Posted on<br />'.date("d.m.y H:i", $r['posted']).'<br /> <br />Msg no. '.$r['id'].'<br />'; if($user->level == '9'){ echo '<br /><a href="main.php?sk=wall&delete='.$r['id'].'" class="delete">Delete</a>'; } echo '</div> <div style="float:left; width:80px; text-align:center;"><img src="resize_image.php?file='.$rw['avatar'].'&size=70" /> <br /><a href="#">'.ucwords($rw['username']).'</a></div> <div style="margin-right:120px; margin-left:95px;"><p>'.$r['comment'].'</p></div> </div> </div>'; } echo '<br />'; The javascript removes the.. <div style="float:right; width:105px;">Posted on<br />'.date("d.m.y H:i", $r['posted']).'<br /> <br />Msg no. '.$r['id'].'<br />'; if($user->level == '9'){ echo '<br /><ahref="main.php?sk=wall&delete='.$r['id'].'"class="delete">Delete</a>'; } echo '</div> from the page, though not from the database for some reason. What should happen, is that the whole thing from first div opening, to the last div to be removed from the page, and then that row to be deleted from the database. It doesn't do it though. Hope you can help >.< Link to comment https://forums.phpfreaks.com/topic/197294-php-and-javascript-delete/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.