.Darkman Posted March 9, 2007 Share Posted March 9, 2007 Hello All, I have a blog system. And i have a simple Admin Panel. I have one file called "manage_categories.php" It is : <?php $query = "SELECT id, title FROM categories"; $result = @mysql_query($query); if ($result) { echo '<div align="center"> <table border="0"> <tr> <td><b>ID</b></td> <td><b>Title</b></td> <td><b>Delete</b></td> <td><b>Edit</b></td> </tr>'; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo '<tr> <td>'.$row['id'].'</td> <td>'.$row['title'].'</td> <td><a href="delete_category.php?id='.$row['id'].'">Delete</a></td> <td><a href="edit_category.php?id='.$row['id'].'">Edit </tr>'; } } else { echo 'Sorry, but we could not retrieve any categories.'; } ?> </table> </div> That displays all the links to edit and delete them. I have the "delete_category.php" as : - <?php include ('login_check.php'); if (isset($_GET['id'])) { include('../includes/mysql_connect.php'); if (is_numeric($_GET['id'])) { $id = $_GET['id']; $query = "DELETE FROM categories WHERE id = $id"; $result = mysql_query($query); include ('header.php'); if ($result) { echo '<h3>Success!</h3><br /> The Category was deleted succesfully.<br /><br />'; } else { echo 'We are sorry to inform you but the Category you chose to delete could not be deleted. Please feel free to try again'; } } else { echo 'Invalid category, please choose a news item.'; } } else { echo 'Before visiting this page please choose a category to delete first!'; } ?> <?php include ('footer.php'); ?> Now what i'd like to do is, merge both of these files into one single file. Also i'd like to say that the manage_categories.php is not accessbile through : http://myadmin.com/manage_categories.php It is accessible only through http://myadmin.com/manage.php?type=category Please do help me with this. I'd also like my edit_categories.php to be merged with these too. Thanks, Link to comment https://forums.phpfreaks.com/topic/41917-merging-two-files/ Share on other sites More sharing options...
benjaminbeazy Posted March 9, 2007 Share Posted March 9, 2007 put the contents of delete file at top of manage file and encapsulate in an if statement like if($_GET[action] == "delete"){ delete file contents here } and change your delete links to <a href="?manage_categories.php&action=delete&id='.$row['id'].'" mimic the same schema for edit categories Link to comment https://forums.phpfreaks.com/topic/41917-merging-two-files/#findComment-203250 Share on other sites More sharing options...
.Darkman Posted March 9, 2007 Author Share Posted March 9, 2007 Cool. Thanks Man. Link to comment https://forums.phpfreaks.com/topic/41917-merging-two-files/#findComment-203264 Share on other sites More sharing options...
benjaminbeazy Posted March 9, 2007 Share Posted March 9, 2007 yup Link to comment https://forums.phpfreaks.com/topic/41917-merging-two-files/#findComment-203265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.