// insert data into the menu table - $menuname or $selectMenuname
// if $menuname is not empty
if (!empty($menuname)) {
// then insert that menu name into the database
$insert1 = "INSERT INTO `menu` (`menuname`, `page_title`)
VALUES ('$menuname', '$pagetitle')";
if (mysql_query ($insert1)) {
// select the last inserted menuid
$query1 = mysql_query("SELECT menuid FROM `menu`") or die ("Could not query because: ".mysql_error());
$row1 = mysql_fetch_assoc($query1);
$menuid = mysql_insert_id();
// then insert the menuid into the pages table
// along with the page's content
$insert3 = "INSERT INTO `pages` (`menuid`, `button`, `page_title`, `content`, `keywords`, `description`, `active`, `images`, `imagenames`)
VALUES ('$menuid', '$button', '$pagetitle', '$pageContent', '$keywords', '$description', '$active', '$images', '$imagenames')";
// if everything is ok
if (mysql_query ($insert3)) {
// go to the next page
header ("Location: page_added.php?pagetitle=".$pagetitle);
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert3.</p>";
}
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert1.</p>";
}
// if $selectMenuname is not equal to none
} elseif ($selectMenuname != 'none') {
// then insert that menu name into the database
$insert2 = "INSERT INTO `menu` (`menuname`, `page_title`)
VALUES ('$selectMenuname', '$pagetitle')";
if (mysql_query ($insert1)) {
// select the last inserted menuid
$query1 = mysql_query("SELECT menuid FROM `menu`") or die ("Could not query because: ".mysql_error());
$row1 = mysql_fetch_assoc($query1);
$menuid = mysql_insert_id();
// then insert the menuid into the pages table
// along with the page's content
$insert3 = "INSERT INTO `pages` (`menuid`, `button`, `page_title`, `content`, `keywords`, `description`, `active`, `images`, `imagenames`)
VALUES ('$menuid', '$button2', '$pagetitle', '$pageContent', '$keywords', '$description', '$active', '$images', '$imagenames')";
// if everything is ok
if (mysql_query ($insert3)) {
// go to the next page
header ("Location: page_added.php?pagetitle=".$pagetitle);
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert3.</p>";
}
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert2.</p>";
}
}
Bookmarks