Jump to content

stupid problem with basic editNews.php


kurbitur

Recommended Posts

I have a small (42 hours) problem with my code trying to edit article (edit.php)

... should be basic

 

When I choose article to edit the data appears in the forms and when hit "update"

it returns no error, but the date didn´t changes in the db

 

less talk - more code .... anyone who can spot what I am doing wrong?

 

<?PHP 
connection to database blah blah 
?> 

<?php 


if(isset($_POST['update'])) 
{ 
//here the id that we post is the same id that we get from url 
//id indicates the id of this data which we are editing 
//id is unique and a particular id is associated with particular data	
$newsid = $_POST['newsid']; 
$date=$_POST['date']; 
$time=$_POST['time']; 
$location=$_POST['location']; 



//updating the table 
$result=mysql_query("UPDATE news SET date='$date',time='$time',location='$location', WHERE newsid=$newsid"); 

//redirectig to the display page. In our case, it is index.php 
header("Location: listNews.php"); 
} 
} 
?> 
<?php 
//for displaying data of this particular data 

//getting id from url 
$newsid = $_GET['newsid']; 

//selecting data associated with this particular id 
$result=mysql_query("select * from news where newsid=$newsid"); 

while($res=mysql_fetch_array($result)) 
{ 
$date = $res['date']; 
$time = $res['time']; 
$location = $res['location']; 


} 
?> 

 

 

 

---- form ----

 

 

<form method="post" action="editNews.php" name="form1"> 

 

each form has

 

<input type="text" name="headline" value="<?php echo $location;?>" id="UserName"> 

 

and

 

<input type="hidden" name="newsid" value=<?php echo $_GET['newsid'];?> 

<input name="update" type="submit" value="update" /> 

 

Most likely there is something that I don´t see :) but "seeing" has taken almost 2 days now

Link to comment
https://forums.phpfreaks.com/topic/251076-stupid-problem-with-basic-editnewsphp/
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.