Wintergreen Posted September 6, 2006 Share Posted September 6, 2006 I have a blog set up now, but I'd like to make an easy way of managing the posts (easier than manually through SSH). The easiest way would be to include a form checkbox on the edit page (the edit page shows one post at a time) and go from there, however I'd like to list all posts with checkboxes by them and be able to select multiple posts to get rid of at a time. My problem with setting this up, though, is that I'm not sure how to pass all the post IDs of the selected posts through to the page that will actually delete them. Each time I've made an edit page or a comment page it always passes in the postid using $_GET, but that won't work in this case because I don't know how many or which posts will be selected for deletion.Any help would be great Link to comment https://forums.phpfreaks.com/topic/19892-blog-post-management-question/ Share on other sites More sharing options...
redarrow Posted September 6, 2006 Share Posted September 6, 2006 i am not sure if somethink like this even works but i come up with this.example only not tested dont no even this is correct sorry.[code]<?php//database connection$query="select * from post";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){echo $record['description'];?><form method="POST" action""><br>delete post<br><input type="radio" name="yes">click for yes.......<br><?php}if(isset($_POST['submit'])){if($record['description']=="yes"){$del="delete from post where description='".$record['description']."'";$del_res=mysql_quey($del);} }?><input type="submit" name="submit" value="delete"></form>[/code] Link to comment https://forums.phpfreaks.com/topic/19892-blog-post-management-question/#findComment-87043 Share on other sites More sharing options...
Wintergreen Posted September 6, 2006 Author Share Posted September 6, 2006 I was thinking, I can do a read of the number of rows that fit the search criteria, and then pass that into the page that deletes the posts. I would have the name of the checkboxes go up one per post, so the first would be post0, second would be post1, etc. So I could do:[code]for ($i = 0; $i <= $postcount; $i++) { if ($_POST['post$i']) { blah blah }}[/code]My question now is will the $_POST['post$i'] part work? Link to comment https://forums.phpfreaks.com/topic/19892-blog-post-management-question/#findComment-87081 Share on other sites More sharing options...
Barand Posted September 6, 2006 Share Posted September 6, 2006 try something like[code]<?phpinclude 'db2.php';if (isset($_POST['submit'])) { $idlist = join (',', $_POST['delbox']); mysql_query ("DELETE FROM mytable WHERE id IN ($idlist) ");}$sql = "SELECT id, description FROM mytable";$res = mysql_query($res) or die(mysql_error());echo '<FORM method="POST">';while (list ($id, $desc) = mysql_fetch_row($res)) { echo "<input type='checkbox' name='delbox[]' value='$id'> "; echo "$desc<br>" ;}echo "<input type='submit' name='submit' value='Delete selection'>";echo '</FORM>';?>[/code] Link to comment https://forums.phpfreaks.com/topic/19892-blog-post-management-question/#findComment-87094 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.