'.$title.'

'; // Get the page id and action $id = $_GET['id']; $action = $_GET['action']; // If the id is null/blank if ($id == '') { // Get the pageid and title of all pages $result = run_query("SELECT pageid, title FROM pages"); // Transform it into an associative array $pages = array(); while ($row = $result->fetch_assoc()) { $pages[ $row['pageid'] ] = $row['title']; } // Generate a dropdown menu of all the pages echo '
'. return_option_select('id',$pages,'Select a page').'
'; } // If action is update else if ($action=='update') { // Get the posted form data $title = $_POST['title']; $content = addslashes($_POST['content']); $parent = $_POST['parent']; // Form the query $sql = "UPDATE pages SET title = '$title', content = '$content', parent = '$parent' WHERE pageid='$id'"; // Run the query run_query($sql); // Echo feedback echo '

'.$id.' was updated from pages

'; } // If the id is given but action is not update else { // Get all the pages to generate the parent drop down $result = run_query("SELECT pageid, title FROM pages"); $pages = array(); while ($row = $result->fetch_assoc()) { $pages[ $row['pageid'] ] = $row['title']; } // Get the data for the selected page $result = run_query("SELECT * FROM pages WHERE pageid='$id'"); $values = $result->fetch_assoc(); // Ouput the edit form echo '
'.$id.'
'. return_input_text('title','Page Title',$values['title'],true). return_textarea('content','Page Content',$values['content']). return_option_select('parent',$pages,'Parent Page',$values['parent']).'
'; } echo ''; echo_foot(); ?>