Jump to content

[SOLVED] Update not working ... please help


anoopd

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.