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
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:
<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_pages, 0);
$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.