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 Like 22 Dislike
Previous forums Next forums
Other forums

Preserving user-entered linebreaks
Hi, I'm building a web 2.0 thingy from scratch and I wanna display text which users input. It's all

Anti Spam Code
Ok where do i start? Probably by telling you I have very little working knowledge of PHP and that I

http to https
Hi,

Is there any specific method/condition to move an http:// page to https:// ?

Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called d

Registration
ok so i have a site where people can register and login which works now thanks to someone on here th

Referential Integrity problem when inserting into 2 tables at same time
Hello Everyone,

Im relativity new to PHP and MySQL and i have come up against a problem. i h

PHP url branch??
Functionally, using PHP, I'm doing a test of login input submitted by a user via an html form in a f

IF STATEMENT HELP
Hi
i have created a calendar from a table:

Code: Calendar: October 2009
<table w

Displaying pictures
i have worked my way through storing images in directory and storing the location in mySQL db.Now i

Run function every 5 mins ??
I have a function PostMessage()

How can I run it every 5 mins ??

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash