i have a problem with editing and updating my data on my database.
i cant pass or echo the data from the database into text boxes.
heres the php script.

// this script is for displaying the information oof the logged in member. and contains the link to edit the displayed info.
<?php
    $result = mysql_query("select * from info where idnum = ".$_SESSION['valid'],$conn);

    echo "</br><b>Profile Info:</b><br/>";
    echo "<center><table width='50%' top=500px left=300 border=1>";
    echo "<tr bgcolor='#CCCCCC'><td>Name</td><td>Surname</td><td>Email</td></tr>";


    while($row = mysql_fetch_assoc($result))
    {

        $name = $row['name'];
        $surname = $row['surname'];
        $email = $row['email'];
        echo "<tr><td>$name</td><td>$surname</td><td>$email</td></tr>";


    }
    echo "</table>";
    echo "</br>";
    echo "<td><a href=\"edit.php?idnum=$row[idnum]\">Edit Information</a>";

?>



//this script is supposedly for retrieving the info of the logged in user into textboxes. but it doesnt quite work.
<?php
$id = $_GET['idnum'];
$result1=mysql_query("select * from info where idnum=$id",$conn);

while($res=mysql_fetch_array($result1))
{
    $name = $res['name'];
    $surname = $res['surname'];
    $email = $res['email'];
}
?>
<html>
<title>Edit Data</title>
<body>

<br/><br/>
<form name="form1" method="POST" action="edit.php">
<table border="0">
   <tr>
    <td>Name</td>
    <td>
        <input type="text" name="name" value=<?php echo $name;?>>    </td>
  </tr>
  <tr>
    <td>surname</td>
    <td>
        <input type="text" name="surname" value=<?php echo $surname;?>>     </td>
  </tr>
<tr>
    <td>Email</td>
    <td>
        <input type="text" name="email" value=<?php echo $email;?>>     </td>
  </tr>
<tr>
    <td><input type="hidden" name="id" value=<?php echo $_GET['idnum'];?>>    </td>
    <td><input type="submit" name="update" value="Update"></td>
  </tr>
</table>
</form>

instead of

value=<?php echo $name;?>> 

use:

value=&quot;<?php echo $name;?>&quot;

as &quote allows you to use two quotation marks in the diffent languages HTML and PHP.

Also you have mots of typos like here: value=<?php echo $name;?>> toy have two > at the end.

Didnt manage to geta good looka t the code and I'm dishing up dinner but they're some tips on the go.

Antoher example:

$result = mysql_query("select * from info where idnum = ".$_SESSION['valid'],$conn);

should be:

$result = mysql_query("SELECT * FROM `info` WHERE `idnum` = '".$_SESSION['valid'],$conn."');

(Notice the last few characters...)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.