here is my code with the updates made…the only thing it wont do is when you click submit it wont update the data and show “Information update” …
can someone get it working before you make a comment… this is frustrating me any help is appreciated…
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<link rel="STYLESHEET" type="text/css" href="common/common.css">
<script src="common/common.js" type="text/javascript"></script>
</head>
<body bgcolor="#000000">
<?php
include ("connect.php");
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the news
$result = mysql_query("SELECT * FROM news ORDER BY id");
//run the while loop that grabs all the news scripts
while($r=mysql_fetch_array($result))
{
//grab the title and the ID of the news
$title=$r["title"];//take out the title
$id=$r["id"];//take out the id
//make the title a link
echo "<span class='editbut'><a href='editnews2.php?cmd=edit&id=$id'>$title - Edit</a></span>";
echo "<br>";
}
}
?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!($_POST["submit"])) //if (!isset($_POST["submit"]))
{
$id = $_GET["id"];
$sql = "SELECT * FROM news WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="editnews2.php" method="post">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">
<span class='content'>Date:</span><INPUT TYPE="TEXT" NAME="date" VALUE="<?php echo $myrow["date"] ?>" SIZE=20><br>
<span class='content'>Title:</span><INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br>
<span class='content'>Article:</span><TEXTAREA NAME="article" ROWS=10 COLS=30><? echo $myrow["article"] ?></TEXTAREA><br>
<input type="hidden" NAME="cmd" value="edit">
<input type="submit" NAME="submit" value="submit">
</form>
<? } ?>
<?
if ($_POST["$submit"])
{
$id = $_POST["id"];//added
$date = $_POST["date"];
$title = $_POST["title"];
$article = $_POST["article"];
$sql = "UPDATE news SET date='$date',title='$title',article='$article' WHERE id=$id";
$result = mysql_query($sql);
echo "<TABLE width='100%' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td width='10' bgcolor='#cc0000'>
<img src='images/trans.gif' width='10' height='1' border='0'><br>
</td>
<td width='100%' bgcolor='#cc0000'>
<span class='content'>Information Updated.</span><br>
<span class='editbut'><a href='index.php' target='_parent'>Home</a></span><br>
</td>
</tr>
</table>";
echo "------------------------------------------------------------------<br><br>";
}
}
?>
</body>
</html>