problem in retrieve and display data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sherry526
Forum Newbie
Posts: 1
Joined: Sat Jul 17, 2010 9:39 am

problem in retrieve and display data

Post by sherry526 »

i'm facing some problem in retrieving record from database(MYSQL) and display the record in form..

it is a UPDATE NEWS php script...

here is my coding

Code: Select all

<title>Edit News</title>

<?php


include("config.php");

   $newsid = $_GET['newsid'];

   if(isset($_POST['submit']))
  {

      $title = $_POST['title'];
      $text1 = $_POST['text1'];
      $text2 = $_POST['text2'];



         $result = mysql_query("UPDATE news SET title='$title', text1='$text1', text2='$text2' WHERE newsid='$newsid' ",$connect);

          echo "<b>Thank you! News UPDATED Successfully!<br>You'll be redirected to Home Page after (4) Seconds";
          echo "<meta http-equiv=Refresh content=4;url=index.php>";
}
elseif($newsid)
{

        $result = mysql_query("SELECT * FROM news WHERE newsid='$newsid' ",$connect);
        while($myrow = mysql_fetch_assoc($result))
             {
                $title = $myrow["title"];
                $text1 = $myrow["text1"];
                $text2= $myrow["text2"];
?>
<br>
<h3>Edit News</h3>

<form method="post" method="POST">
<input type="hidden" name="newsid" value="<? echo $myrow['newsid']?>">

Title: <input name="title" size="40" maxlength="255" value="<? echo $title;?>">
<br>
Text1: <textarea name="text1"  rows="7" cols="30"><? echo $text1;?></textarea>
<br>
Text2: <textarea name="text2" rows="7" cols="30"><? echo $text2;?></textarea>
<br>
<input type="submit" name="submit" value="Update News">
</form>
<?php
              }//end of while loop

  }//end else
?>

The result i get is :
Image

the update function is working, i just cant display those retrieved data onto the form for further record editing.

appreciate for any assistance . TQ !
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: problem in retrieve and display data

Post by liljester »

your php.ini does not have short tags enabled. to fix it change <? echo $varl ?> to <?php echo $var; ?>
Post Reply