+ Reply to Thread
Results 1 to 8 of 8

Thread: MYSQL - backend admin enter blurb in textarea to display on front end

  1. #1
    goldy30's Avatar
    goldy30 is offline x10Hosting Member goldy30 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    60

    Question MYSQL - backend admin enter blurb in textarea to display on front end

    basics as it's all still pretty new for me here.

    I want to allow admin to select index, page2, page3 .. so on, from a select list and below that write text into a textarea in the backend, save and store it into petitions db - pages table - in the 'blurb' field.

    They should be able to go through and select any page from the drop down list and write something and it will display on the page they selected on the front end.

    how do I make the select list dynamic and what syntax do I write to save the blurb into the blurb field in the pages table?

    I know I'd SELECT * FROM `pages` WHERE .... actually I'm not sure?? Because I'm not sure I have the right fields in the pages table.

    These are the fields I have:

    Table: pages
    • pages_id
    • pagename
    • blurb
    If the client wants to add a page in future it would add an ID I think.?

    Any help here?
    Last edited by goldy30; 11-19-2008 at 10:17 AM.

  2. #2
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: MYSQL - backend admin enter blurb in textarea to display on front end

    Quote Originally Posted by goldy30 View Post
    basics as it's all still pretty new for me here.

    I want to allow admin to select index, page2, page3 .. so on, from a select list
    Not sure about the approach here - do you mean when an administrator has logged into the front end site.. and if so, why would you want to select pages from a select list (or drop down menu)

    As a literal translation, all you would do is put in an authorisation script into the top of the page that determines what level of access you have (or just based on your username) and whether you can access that page or not. If you can't, it will re-direct you to another page.

    and below that write text into a textarea in the backend,
    Ok this is where I got confused - in the first section, you refer to selecting, and pages - then above, you refer to back-end!

    Do you mean that you type into a simple text box (front end) which then saves to back-end database when you click submit?

    save and store it into petitions db - pages table - in the 'blurb' field.
    Ah - it becomes clearer. - this is simple enough.

    storing data (a new record) requires the "INSERT INTO" SQL statement. However, if you are just changing an existing record, you need to use "UPDATE" SQL statement, based on a record it has already found using a "SELECT" statement.


    They should be able to go through and select any page from the drop down list and write something and it will display on the page they selected on the front end.

    how do I make the select list dynamic and what syntax do I write to save the blurb into the blurb field in the pages table?

    I know I'd SELECT * FROM `pages` WHERE .... actually I'm not sure?? Because I'm not sure I have the right fields in the pages table.

    These are the fields I have:

    Table: pages
    • pages_id
    • pagename
    • blurb
    If the client wants to add a page in future it would add an ID I think.?

    Any help here?
    *Head hurts*

    What I think you are trying to achieve is a page with a drop-down menu that lists other pages dynamically from the db and a text box underneath that will insert back into the db.??

    The drop down menu looks a bit like this within a <form></form> tag (once you have created your recordset)

    PHP Code:
    <select name="page" id="page">
    <?php
    do { ?>
          <option value="<?php echo $row_recordset_pages['pagename']?>">
          <?php echo $row_recordset_pages['pagename']?></option>
    <?php } while ($row_recordset_pages mysql_fetch_assoc($recordset_pages));
    $rows mysql_num_rows($recordset_pages);
    if(
    $rows 0) {
         
    mysql_data_seek($recordset_pages0);
         
    $row_recordset_pages mysql_fetch_assoc($recordset_pages);
      }
    ?>
    </select>
    However, I am struggling to understand what the purpose of this is.

    It is a comment box on various other webpages so viewers can leave opinions?? If so, you will need a field that stores the URL so that when the page is selected from the drop-down list, it will know where to re-direct to.

    But this is confusiing because you mention that admin should have access - so why would admin want to do this....?

    That said, your SQL statement is very simple.

    SELECT * FROM PAGES ORDER BY pages_id

    WHERE is only used when you want to filter some records out.

    This statement selects everything from that table and sorts it by (whatever field you want to sort it by)

    This "recordset" can then be used to "feed" either a drop-down menu or a simple table that lists all records.

    I think we need better clarification of what you want.
    Last edited by freecrm; 11-19-2008 at 11:50 AM.

  3. #3
    goldy30's Avatar
    goldy30 is offline x10Hosting Member goldy30 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    60

    Question Re: MYSQL - backend admin enter blurb in textarea to display on front end

    I've managed to confuse everyone with this and always results in minimal progress.

    Non members area - frontend

    Admin backend - add, edit, delete members, pages, products, posts...etc.

    I'll put it in a case scenario and you tell me the best way to do it. Your building a site for a client and they want to be able to write and edit what ever they want to each page. How would you allow admin to manipulate a block of text " the blurb" on each page.

    I was thinking that the admin could go to a "manage content" link and they would have the choice of selecting which page they want to edit the content, once they select a page the text which is currently on the page already will display in a textarea. (they can see what they are editing) They update the content for that page and save it into the db. the page which was edited holds a select query for that content and echo's the blurb onto the page.

    I'm not sure I can make that any clearer. How would you do it??

  4. #4
    mephis's Avatar
    mephis is offline x10Hosting Member mephis is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    39

    Re: MYSQL - backend admin enter blurb in textarea to display on front end

    Quote Originally Posted by goldy30 View Post
    basics as it's all still pretty new for me here.

    I want to allow admin to select index, page2, page3 .. so on, from a select list and below that write text into a textarea in the backend, save and store it into petitions db - pages table - in the 'blurb' field.

    They should be able to go through and select any page from the drop down list and write something and it will display on the page they selected on the front end.
    doing the dropdown list:

    PHP Code:
    $result mysql_query("SELECT * FROM `pages`");

    echo 
    "<select>";
    while (
    $row mysql_fetch_assoc($result)) {
        echo 
    "<option value=\"{$row['pages_id']}\">{$row['pagename']}</option>";
    }
    echo 
    "</select>"

    Quote Originally Posted by goldy30 View Post
    how do I make the select list dynamic and what syntax do I write to save the blurb into the blurb field in the pages table?
    making the select list dynamic would probably be best done with AJAX, or you can just add an OnChange trigger that would reload the page (you can pass the `page_id` along to load the page content as well).


    putting the text content into the `blurb` field involves setting up a form that submits the text data (`blurb`) and either the `page_id` or `pagename` (I would prefer the `page_id`).
    in the database, the field blurb should be TEXT (that's what I use anyway)


    The form:
    PHP Code:
    <form action="insert.php" method="POST">
    <input type="hidden" name="page_id" value="<?php echo $page_id?>" />
    <textarea name="blurb"><?php echo $blurb?></textarea>
    <input type="submit" name="submit" value="Submit" />
    </form>
    The code (insert.php):
    PHP Code:
    $page_id $_POST['page_id'];
    $blurb $_POST['blurb'];

    mysql_query("INSERT INTO `pages` (`blurb`) VALUES ('$blurb') WHERE `page_id` = '$page_id'"); 

    Edit:
    Of course, you can always put these three bits of code together and run everything off just one script
    Last edited by mephis; 11-19-2008 at 06:47 PM.

  5. #5
    goldy30's Avatar
    goldy30 is offline x10Hosting Member goldy30 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    60

    Talking Re: MYSQL - backend admin enter blurb in textarea to display on front end

    This is good, I was having trouble making the connection for quite some time but I still need a couple of things sorted out.

    Talking to my teacher, who never seems to have enough time for me, she suggested that I keep an input for the title on the page as well as the text area (blurb). "You have to assume everyone is stupid." She says keeping it simple for the client is better that leaving them with one text area and assuming they'll get the basic html right.

    So in my pages table I have pages_id, title, blurb and page name. I was thinking to duplicate the <php echo $title ?> in the value of the input... like you did in the text area but I'm not sure this is right??

    <input type="text" name="title" value="<php echo $title ?>">

    Plus the sql query's you wrote would need extra stuff in them for the title.

    How are they suppose to add a new page?

    Thanks for all your help.

  6. #6
    goldy300's Avatar
    goldy300 is offline x10Hosting Member goldy300 is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    Australia
    Posts
    33

    Red face Re: MYSQL - backend admin enter blurb in textarea to display on front end

    http://daniel.classroomonline.info/g...dmin/admin.php

    Here's a link to the admin area where you can see where I have the select list but with the code you have me I had to manually put in the page_id = 1, pagename = index and blurb = Welcome; but when I click edit on the index, the next page dosen't display the blurb welcome!

    The title box is inactive for now but this should give you a better understanding of what I want to achieve.

    Also, like I said, I need to be able to enter the details to create new id's and pagenames without doing it manually.

  7. #7
    RossSchVle is offline Banned RossSchVle is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    Here/Now/Never
    Posts
    98

    Red face Re: MYSQL - backend admin enter blurb in textarea to display on front end

    Quote Originally Posted by goldy300 View Post
    http://daniel.classroomonline.info/g...dmin/admin.php

    Here's a link to the admin area where you can see where I have the select list but with the code you have me I had to manually put in the page_id = 1, pagename = index and blurb = Welcome; but when I click edit on the index, the next page dosen't display the blurb welcome!

    The title box is inactive for now but this should give you a better understanding of what I want to achieve.

    Also, like I said, I need to be able to enter the details to create new id's and pagenames without doing it manually.
    So you need the system to create a new page id and title everytime a petition is submitted and then allow the admin to edit the page title and page info and then this to be displayed to the front end user - so you want a basic cms? :happysad:

  8. #8
    goldy30's Avatar
    goldy30 is offline x10Hosting Member goldy30 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    60

    Cool Re: MYSQL - backend admin enter blurb in textarea to display on front end

    Quote Originally Posted by RossSchVle View Post
    So you need the system to create a new page id and title everytime a petition is submitted and then allow the admin to edit the page title and page info and then this to be displayed to the front end user - so you want a basic cms? :happysad:

    No, not every time a petition is submitted. This part is specifically for admin to write their own content to the page. That way if the written content on the page is old and out of date, later they can go and edit it themselves.

    I think I could add the page names manually and If later the client wishes to add additional pages I could provide a link to do so.

    But what you say about every time a petition is added, is exactly what needs to happen when a user creates a petition from the front end; create petition page.
    Last edited by goldy30; 11-20-2008 at 07:19 AM. Reason: wrong response

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. Replies: 14
    Last Post: 09-29-2008, 07:07 PM
  3. New Site-Suggestions?
    By mnoutside in forum Review My Site
    Replies: 9
    Last Post: 08-27-2008, 07:01 AM
  4. MySQL Issues Here
    By Corey in forum Service Alerts
    Replies: 304
    Last Post: 01-06-2008, 09:10 PM
  5. Have a problem with my forum
    By tikloos in forum Scripts & 3rd Party Apps
    Replies: 43
    Last Post: 01-19-2006, 01:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers