home *** CD-ROM | disk | FTP | other *** search
- <?php
- //connect to the database
- $conn = mysql_connect("localhost","root","pwd");
- //choose the cms db
-
- mysql_select_db("cms", $conn);
- if ($_POST['btnDelete'] != "")
- {
- //update the content
- $sql = "DELETE FROM tblContent WHERE contentID = " . $_POST['contentID'];
- if (mysql_query($sql, $conn))
- {
- $deleted = true;
- }
- }
-
- if ($_GET['btnSelect'] != "")
-
- {
- $delete = true;
- //get the content
- $article = mysql_query("SELECT contentTitle,contentText ,catID FROM tblContent WHERE contentID = " . $_GET['contentID'], $conn);
- while ($articlerow = mysql_fetch_array($article)) {
- $title = $articlerow['contentTitle'];
- $content = $articlerow['contentText'];
- $catID = $articlerow['catID'];
-
- //query the database for a list of categories - for the navigation menu
- $result = mysql_query("SELECT catID, catName, catDesc FROM tblCat", $conn);
- }
-
- }
- else
- {
- //query the database for a list of content
- $result = mysql_query("SELECT contentID, contentTitle FROM tblContent ORDER BY contentTitle", $conn);
- }
- ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
- <html>
- <head>
- <title>CMS Admin</title>
- <link rel="stylesheet" type="text/css" href="../global.css" />
- </head>
-
- <body>
- <div id="banner">
- <p> </p>
- </div>
- <div id="navigation">
- <ul class="main">
- <li><a href="add.php">Add Content</a></li>
- <li><a href="edit.php">Edit Content</a></li>
- <li><a href="delete.php">Delete Content</a></li>
- </ul>
- </div>
- <div id="content">
- <h1>Delete Content</h1>
- <?php
- if($deleted == true)
- {?>
- <p><strong>Your record has now been deleted from the database.</strong></p>
-
- <?php
- }
- if($delete == true)
- {
- ?>
- <form method="post" action="delete.php">
- <p>Are you sure that you want to delete this record?</p>
- <p><input type="submit" name="btnDelete" value="Delete Record" /> <input type="button" name="btnQuit" value="Do not delete" onclick="window.location='delete.php';" /></p>
- <h2><?=$title?></h2>
- <p><?=$content?></p>
- <input type="hidden" name="contentID" id="contentID" value="<?=$_GET['contentID']?>" />
- </form>
-
- <?php
- }
- else
- {
- ?>
- <p>Select the content you wish to delete from the database by selecting the corresponding radio button and clicking delete.</p>
- <form method="get" action="delete.php">
- <p>
- <?php
- while ($row = mysql_fetch_array($result)) {
- print("<input type=\"radio\" name=\"contentID\" value=\"" . $row[contentID] . "\" /> ");
- print($row[contentTitle] . "<br />\n");
- }
- ?>
- </p>
- <p><input type="submit" name="btnSelect" value="Delete Record" /></p>
- </form>
- <?php
- }
- ?>
-
- </div>
- </body>
- </html>
-
-
-