
Originally Posted by
goldy30
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>";

Originally Posted by
goldy30
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