The problem I ran into is that the form does NOT update the positions of other sections that already exist, so you may end up with Products and Contact Us both being assigned to the second position. I'm not sure if I need to use some if / then statements to reassign positions to sections that were already in the database or if there's an array function that will automatically 'slide' the existing sections over so if a new section is designated position 2, all the old sections that had been position 2 or higher will be changed to position n+1.
I've done some reading and worked through a bunch of tutorials, but php is still new to me, so any advice would be much appreciated.
I've pasted some of the code below:
Code: Select all
$id = mysql_prep($_GET['page']);
$menu_name = trim(mysql_prep($_POST['menu_name']));
$position = mysql_prep($_POST['position']);
$visible = mysql_prep($_POST['visible']);
$content = mysql_prep($_POST['content']);
//Database submission only proceeds if there were NO errors.
if(empty($errors)){
$query = "UPDATE pages SET
menu_name = '{$menu_name}',
position = {$position},
visible = {$visible},
content = '{$content}'
WHERE id = {$id}";
$result = mysql_query($query, $connection);