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"';

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

Exporting new records
Trying to figure out the best way to set this up.

People register my site.

Their prof

Calander layout
Hi i know this sounds like a simple question but i cant find the answer to it anywhere i have added

noob question
i traying to do a php form with auto replay for both(me and the user who send me a mail),

a u

want a code for uploading and downloading
i m trying to upload and download to my site..i need upload and download code ...i use a code for up

There was a problem with the request. (Code: 0)
Any Idea what could cause this? I get it randomly at best. But with both IE and FF. It derives from

Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system

Say I go to h

Website Direction...
I recently used this code to try and make it so the page loads as http://www.domain.com/ when you ty

Array help
Hello i got this code to fetch data from database but it is not working it displays
7
Array

Accessing Infotype data in dialog program
Hi All
In Dialog programs attributes I didn't see any logical database field. How can I access

Filtering an Array Based on Value
I have a very simple script set up that pulls data from a database and is output using this code:

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