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
22
Other forums
Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h
WELCOME SCREEN
first of all let me tell you what does my script do,
it´s a very simple query to show a e
search function
HI guys,
if anyone could point us in the right direction of how to do this, or provide some t
Strange php code found on my website
I got hacked and the following code was placed within my files:
Code: [Select]<?
/*
Filtering for a phrase using pregmatch
Here is my code which looks for addresses which start with ' src=" '
Code: [Select]preg_
Help to integrate whois Domain Details to website
Hi,
can i know is their any php script r methods to add domain details to my website.
weeks in a year
hi,
i found this snippet on php.net
QuoteFor the week number for weeks starting on Sunday:
Calculating a rating by adding number of points and dividing by number of items
I have a site that users can post links to files to download. They can rate these files on a 1-5 sca
Polymorphism
Was wondering if someone could explain this a little better to me. I had always assumed that it had
Output Full URL of Current Page
Let's say I am currently viewing a dynamic page:
http://www.mydomain.com/directory/index.php