When I edit the news currently, the text box is empty. I would like to see the existing news item shown in the text box to make editing a news item easier.
Any help would be greatly appreciated
MYSQL info
Code: Select all
CREATE TABLE `news` (
`newsid` int(11) NOT NULL default '0',
`dtime` datetime default NULL,
`title` varchar(255) NULL,
`text` text,
PRIMARY KEY (`newsid`)
);Code: Select all
<?php
require("../head.php");
require("../common/dbconn.php");
if($submit)
{
$title = mysql_real_escape_string($_POST['title']);
$text1 = mysql_real_escape_string($_POST['text']);
$result = mysql_query("UPDATE news SET title='$title', text='$text' WHERE newsid='$newsid' ",$connect);
echo "<b>News UPDATED Successfully!<br>You'll be redirected to Home Page after (4) Seconds";
echo "<meta http-equiv=Refresh content=4;url=index.php>";
}
elseif($newsid)
{
$result = mysql_query("SELECT * FROM news WHERE newsid='$newsid' ",$connect);
while($myrow = mysql_fetch_assoc($result))
{
$title = $myrow["title"];
$text1 = $myrow["text"];
?>
<br>
<h3 class="n">Edit Frontpage News</h3>
<form method="post" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="newsid" value="<? echo $myrow['newsid']?>">
<span class="n">Title</span>:
<input name="title" class="form" value="<? echo $title; ?>" size="40" maxlength="255">
<br>
<span class="n">Text</span>:
<textarea name="text" cols="150" rows="10" class="form"><? echo $text; ?>
</textarea>
<br>
<br>
<input name="submit" type="submit" class="form" value="Update News">
</form>
<span class="n">
<?
}//end of while loop
}//end else
?>