Hello again, why isnt this working? Update statement
Posted: Tue Apr 13, 2004 5:30 pm
im making a simple database driven site, and all was go. I started working on the admin page. Adding a page worked fine. Editing one went down the tubes.
ok, what the page does is make a form, displays radio buttons with each pages ID, then, hit submit, and this happens:
it didnt even select the correct page...
thanks in advanced
ok, what the page does is make a form, displays radio buttons with each pages ID, then, hit submit, and this happens:
Code: Select all
<?
if ($_GET['p'] == "epage") {
if ($_POST['title'] == "") {
$q=0;
$id=$_POST['id'];
$sql=mysql_query("SELECT * FROM pages WHERE id=$id");
$rows=mysql_numrows($sql_getlinks1);
while ($q < $rows) {
$thetitle=mysql_result($sql_getlinks1,$q,"title");
$theid=mysql_result($sql_getlinks1,$q,"id");
$thecontent=mysql_result($sql_getlinks1,$q,"content");
$theorder=mysql_result($sql_getlinks1,$q,"l_order");
++$q;
}
?>
<font size="2">
<form action="admin.php?p=epage" method="post">
<input type="hidden" name="id" value="<? echo "$id"; ?>">
Title: <input type="text" name="title" value="<? echo "$thetitle"; ?>"> (will show up as the link)<br>
Order: <input type="text" name="order" value="<? echo "$theorder"; ?>"> (order on navbar, 0,1,2..)<br>
Content:<br>
<textarea name="content" cols="60" rows="15"><? echo "$thecontent"; ?></textarea><br>
<input type="submit" value="EDIT">
</form>
<?
}
else{
$id=$_POST['id'];
$title = stripslashes($_POST['title']);
$l_order = stripslashes($_POST['order']);
$content = stripslashes($_POST['content']);
$query = "UPDATE pages set title='$title', l_order='$l_order', content='$content' WHERE id='$id'";
$result = mysql_query($query);
if ($result) {
echo "Your page has been updated succesfully.<br>
<a href=admin.php>Back to Admin</a>";
}
else{
echo "Sorry, your page has not been updated.<br>" . mysql_error() . "<br>
<a href=admin.php>Back to Admin</a>";
}
}
}
include 'footer.html';
?>thanks in advanced