Jump to content

Not Updating


Xtremer360

Recommended Posts

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 (); 
     
    }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.