Hi all!
I am trying to create an admin area, cms like for a website.
In my admin.php - the home for the admin area, I have a drop down list with the existing pages, being pulled in from the database, and showed like options:
<form action="../edit_page.php" method="get">
<?php
$result = mysqli_query ($myConnection, $query);
echo "<select class=\"boxstyles\" name='linklabel'>";
echo "<option>Choose A Page To Edit</option>";
// printing the list box select command
while($nt=mysqli_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[id]>$nt[linklabel]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>
<input type="submit" name="formSubmit" value="Go">
</form>
When hitting submit, the error displays:
Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\wamp\www\mycms\administrator\edit_page.php on line 11
I am trying to redirect to this page: edit_php, where I want to use the unique id from the database, to prepopulate the form fields in the edit_page.php, makes sence I hope?
My edit.php looks like this:
<?php require_once('login/auth.php'); ?>
<?php error_reporting(E_ALL ^ E_NOTICE); ?>
<?php
include_once "connect_to_mysql.php";
if (isset($_GET['formSubmit'])) {
// Query the body section for the proper page
$sqlCommand = "SELECT pagetitle, linklabel, heading, pagebody FROM pages WHERE id=$nt[id] LIMIT 1";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$pagetitle = $row["pagetitle"];
$linklabel = $row["linklabel"];
$heading = $row["heading"];
$pagebody = $row["pagebody"];
$pagebody = str_replace("<br />", "", $pagebody);
}
mysqli_free_result($query);
}
?>
There is a form further down the page, where I am echo'ing out the variable-names automatically - Again these form fields should contain the relevant test for editing, - according the option clicked in the dropdown list..
But I am not sure how to grab that info in my edit_page.php???
I am trying to use the id, but obviously I am doing it incorrectly, and I cant seem to fihure out how to do it, not very experienced am i :-)
I hope my problem is clear, and someone can see what I should do?
The best,
Klemme