anoopd Posted October 16, 2009 Share Posted October 16, 2009 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 ........ echo '<a href="addedit.php?edit&id='.$row['id'].'" title="Edit This Member"'; 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 <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 Link to comment https://forums.phpfreaks.com/topic/177873-solved-update-not-working-please-help/ Share on other sites More sharing options...
anoopd Posted October 16, 2009 Author Share Posted October 16, 2009 it is working now .. a small change.. Added $id=$row[0]; in elseif(isset($_GET['edit'])) condition and changed where news.id= "$id" to where news.id= "'.$_POST[id].'"' Link to comment https://forums.phpfreaks.com/topic/177873-solved-update-not-working-please-help/#findComment-937857 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.