Update not working ... please help
Posted on
16th Feb 2014 07:03 pm by
admin
Hi,
I am trying to update a row using an edit form by passing id of the row .. but it is not working .. can anybody find what went wrong ........
Code: [Select]echo '<a href="addedit.php?edit&id='.$row['id'].'" title="Edit This Member"';
Did you know?Explore Trending and Topic pages for more stories like this.
echo '><img src="images/edit.png"></a>
if(isset($_GET['edit']))
{
$sql="select * from news where id=$_REQUEST[id]";
$row=mysql_fetch_row(mysql_query($sql));
$action="editnews";
$news=$row[2];
$subject=$row[1];
$button='Update news';
include 'newsForm.php';
exit();
}
if (isset($_POST['action']) and $_POST['action'] =='Update news')
{
$id=$_REQUEST['id'];
$sql='update NEWS SET news="'.$_POST['news'].'",subject ="'.$_POST['subject'].'",added=curdate() where news.id= "$id"';
if(mysql_query($sql))
echo "Updated";
} newsForm.php
Code: [Select]<form action=?<?php echo $action; ?> method="post">
<p><label>News Subject :</label><input name="subject" type="text" size="60" value="<?php echo $subject; ?>"></p>
<p><label>News :</label><textarea rows="20" cols="50" name="news" ><?php echo $news; ?></textarea></p>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<p><input type="submit" name="action" value="<?php echo $button; ?>"></p>
</form>Pleas somebody let me know what went wrong ..Thanks in advance
No comments posted yet
Your Answer:
Login to answer
279
22
Other forums
Change snippet to use CURDATE
I am using time() in the snippet below, I would like to use CURDATE() and have the database setup fo
error reporting
hey everyone
I have a production server in which I want error reporting but only on some page
Table trouble
i have been reading the forum for a few weeks and decided to join. i like the format and the advice
server trace logs
could any one tell me from where do i get error logs in xMII??I want to check the reason for dtabase
TemplatePower & AJAX
Hi all,
I'm currently implementing some AJAX features in my PHP-framework (which is b
Image DPI
Hi.
I allow users to upload images, the user then is able to adjust several settings for the
Multiple forms on the same page (safari)
Hello everyone,
I have 3 forms on the same page, that opens in a new window and submits to a
PHP - HTTP Digest Authentication - Understanding Code Help
Hi Everyone,
This is my first time on your website and please excuse if I am asking silly que
Help with setcookie()
Merry Xmas to those on this foruum
Older guy here with some experience but not allot so please be
PHP Include w/If IE Condition Statement?
I was having a problem with Internet Exploder (big surprise, right?) displaying my drop down menus i