|
Until you sign up you can't do much. Yes, it's free.
|
|
|
|
|
|
|
 | / / / Viewing Topic
|  |
|
|
Update news script. |
| Help! |
|
|
|
Replies: 2 Last Post June 7, 2006 11:05am by PiXiE
|
|
|
|
|
( PiXiE )
24.24.1.1358
Patron
|
Here is the problem. I have a news page. The news entries come from a database. I have no problem inserting new news entries. I'm trying to write code that will edit existing entries. Here is the code (minus the database connection/header stuff): | Code: | <?php if (isset($_POST['submit'])){ $myUpdate = "UPDATE news SET news_title = '$news_title', news_posted_by='$news_posted_by', news_content= '$news_content' WHERE news_id = '".$news_id."'"; $result = mysql_query($myUpdate); if (!$result) { echo "There was a problem. Please try again."; } else { echo "You have updated successfully."; } } else { ?> <div> <form name="form1" method="post" action="news_edithandler2.php?id=<?php echo $news_id ?>"> <div class="label">Title: </div> <div class="input"><input name="news_title" type="text" id="news_title" value="<?php echo $row_myrecord['news_title'] ?>"></div> <div class="label">Posted By: </div> <div class="input"><input name="news_posted_by" type="text" id="news_posted_by" value="<?php echo $row_myrecord['news_posted_by']; ?>"></div> <div class="label">Body: </div> <div class="input"><textarea name="news_content" cols="60" rows="10" id="news_content"><?php echo stripslashes($row_myrecord['news_content']); ?></textarea></div> <div class="input"><input name="submit" type="submit" value="submit" /></div> </form> </div> <?php } ?> | When you first hit the edit button, the current values in the database show up fine in this form. Once I edit the entries and hit submit, "You have updated successfully" is displayed. The weird part is that the database doesn't get updated, but it erases whatever was there before!! What is going on?
|
8:53 am on June 7, 2006 | Joined: July 2002 | Days Active: 1,663 Join to learn more about PiXiE Alberta, Canada | Straight Female | Posts: 4,837 | Points: 34,868
|
|
| |
|
|
|
| Looking for something else?
|
|
|
|
|
|
 | / / / Viewing Topic |  |
|