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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.