Jump to content

Recommended Posts

I have a content management script set up so that the main body of the page can be modified by the website administrator. Basically when the administrator first arrives at the page I want them to see empty text boxes to fill the info and then submit to the database. Once the info has been stored the same page should then show the info in the text boxes and a save changes button now shows and any changes made ti the text then updates the info. What I haven't been able to acheive is to get the script to check the database to see if the info exists, and then show the empty text boxes. I know its probably a real simple thing to do.... but ..help.

 

heres my go at it...

// request info from content number '0' and show in text boxes with save changes button
if ($_REQUEST['content_type_id']== 0 ) {
$sql1 = "SELECT title, body, main_header, content_type_id, author_id, page_id " .
            "FROM cms_content " .
            "WHERE page_id= 'about' AND content_type_id= '0'";
	  		   
    $result1 = mysql_query($sql1,$conn)
    or die(mysql_error());
while ($row = mysql_fetch_array($result1)) {
      extract($row);
  echo ' <h2>Change main header here</h2> ';
//etc etc
         echo ' <input type="submit" class="submit" name="action" ' . 
         "value=\"Save Changes\">\n"; 
//if empty then show empty boxes and submit button.
}
  } else if ($_REQUEST['content_type_id']<'0' ) {
          echo ' <h2>Add main header here</h2> ';
//etc etc 
echo ' <input type="submit" class="submit" name="action" ' . 
         "value=\"Submit New Content\">\n";
  }
// otherwise if user non-admin just show info as should be displayed
} else{
$sql2 = "SELECT title, body, main_header, content_type_id, author_id, page_id " .
            "FROM cms_content " .
            "WHERE page_id= 'about' AND content_type_id= '0'";
	  		   
    $result2 = mysql_query($sql2,$conn)
    or die(mysql_error());

    while ($row = mysql_fetch_array($result2)) {
      extract($row);
//etc etc

I think the issue is in the...

} else if ($_REQUEST['content_type_id']<'0' ) {

bit.

 

any thoughts?

Link to comment
https://forums.phpfreaks.com/topic/202032-if-database-tables-empty-then-do-this/
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.