Xtremer360 Posted February 17, 2009 Share Posted February 17, 2009 The delete part works but it's not updating when I update the content. function editcontent() { $description = $_GET['description']; $query = mysql_query("SELECT * FROM `content` WHERE `description` = '" . $description . "'"); $row = mysql_fetch_array($query); print '<h1 class=backstage>Content Management</h1><br />'; print '<h2 class=backstage>Edit Site Content</h2><br />'; print '<form name="editcontent" method="post" action="backstage.php" id="editcontent">'; print '<table width="100%" class="table2">'; print '<tr>'; print "<td width=\"120\" class=\"rowheading\" valign=\"center\">Short Name:</td><td class=\"row3\"><input type=\"text\" name=\"shortname\" class=\"fieldtext140\" value=\"".$row['shortname']."\"></td>"; print '</tr>'; print '<tr>'; print "<td width=\"120\" class=\"rowheading\" valign=\"center\">Description:</td><td class=\"row3\"><input type=\"text\" name=\"description\" class=\"fieldtext490\" value=\"".$row['description']."\"></td>"; print '</tr>'; print '<tr>'; print '<td width="120" class="rowheading" valign="center">Enable:</td><td class="row3"><select name="enable" class="dropdown">'; print '<option value="Yes" ' . ( $row['enable'] == 'Yes' ? 'selected' : '' ) . '>Yes</option>'; print '<option value="No" ' . ( $row['enable'] == 'No' ? 'selected' : '' ) . '>No</option>'; print '</select></td>'; print '</tr>'; print '<tr>'; print '<td width="120" class="rowheading" valign="center">Line Breaks:</td><td class="row3"><select name="linebreaks" class="dropdown">'; print '<option value="Yes" ' . ( $row['linebreaks'] == 'Yes' ? 'selected' : '' ) . '>Yes</option>'; print '<option value="No" ' . ( $row['linebreaks'] == 'No' ? 'selected' : '' ) . '>No</option>'; print '</select></td>'; print '</tr>'; print '<tr>'; print '<td width="120" class="rowheading" valign="center">Template:</td><td class="row3"><select name="template" class="dropdown">'; $query = 'SELECT * FROM templates'; $result = mysql_query ( $query ); while ( $row = mysql_fetch_assoc ( $result ) ) { if( $row['description'] == $userRow['description'] ) { $selected = 'selected'; } else { $selected = ''; } print "<option value=\"".$row['description']."\" " . $selected . ">".$row['description']."</option>\r"; } print '</select></td>'; print '</tr>'; print '<tr>'; print '<td width="120" class="rowheading" valign="center">Show Heading:</td><td class="row3"><select name="showheading" class="dropdown">'; print '<option value="Yes" ' . ( $row['showheading'] == 'Yes' ? 'selected' : '' ) . '>Yes</option>'; print '<option value="No" ' . ( $row['showheading'] == 'No' ? 'selected' : '' ) . '>No</option>'; print '</select></td>'; print '</tr>'; print '<tr>'; print '<td width="120" class="rowheading" valign="center">Back Link:</td><td class="row3"><select name="backlink" class="dropdown">'; print '<option value="Yes" ' . ( $row['backlink'] == 'Yes' ? 'selected' : '' ) . '>Yes</option>'; print '<option value="No" ' . ( $row['backlink'] == 'No' ? 'selected' : '' ) . '>No</option>'; print '</select></td>'; print '</tr>'; print '<tr>'; print "<td width=\"120\" class=\"rowheading\" valign=\"top\">Content:</td><td class=\"row3\"><textarea name=\"content\" class=\"textarea490x400\">".$row['content']."</textarea></td>"; print '</tr>'; print '</table><br />'; print '<input type="checkbox" name="deletecontent"><span class="table1heading">Delete Content Page?</span><br /><br />'; print '<input type="hidden" name="oldcdescription" value="'.$row['description'].'"> '; print '<input type="submit" value="Edit Content" class="button" name="editcontent"><br /><br />'; print '<input type="button" value="Return to Site Content List" class="button200"><br /><br />'; print '<h2 class="backstage"><input type="button" value="Return to Main Menu" class="button200"></form></h2>'; } //Form was submitted - determine the form if ( isset ( $_POST['deletecontent'] ) ) { $description = mysql_real_escape_string($_POST['description']); $query = "DELETE FROM content WHERE `description` = '".$description."' LIMIT 1"; // Execute the query. // Good. This error checking method is recommended. if (@mysql_query ( $query )) { print '<p>The template has been deleted.</p>'; }else { print '<p>Could not delete the entry because: <b>"' . mysql_error() . '"</b>. The query was '.$query.'.</p>'; } } else if ( isset ( $_POST['editcontent'] ) ) { // Define the query. $description = mysql_real_escape_string($_POST['description']); $shortname = mysql_real_escape_string($_POST['shortname']); $enable = mysql_real_escape_string($_POST['enable']); $linebreaks = mysql_real_escape_string($_POST['linebreaks']); $template = mysql_real_escape_string($_POST['template']); $showheading = mysql_real_escape_string($_POST['showheading']); $backlink = mysql_real_escape_string($_POST['backlink']); $content = mysql_real_escape_string($_POST['content']); $olddescription = mysql_real_escape_string($_POST['olddescription']); $query = "UPDATE content SET `shortname` = '$shortname', `description` = '$description', `enable` = '$enable', `linebreaks` = '$linebreaks', `template` = '$template', `showheading` = '$showheading', `backlink` = '$backlink', `content` = '$content' WHERE `description` = '$olddescription'"; // Execute the query. // Good. This error checking method is recommended. if (@mysql_query ( $query )) { print '<p>The content has been edited.</p>'; } else { print '<p>Could not edit the entry because: <b>"' . mysql_error() . '"</b>. The query was '.$query.'.</p>'; } //mysql_close (); } Quote Link to comment Share on other sites More sharing options...
Brian W Posted February 17, 2009 Share Posted February 17, 2009 Please be more descriptive. Does it give you an error? Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted February 18, 2009 Author Share Posted February 18, 2009 No it doesn't do anything. No error no nothing. 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.