PDA

View Full Version : modify user details



adams2887
06 Apr 2011, 05:15 AM
Hi there, i was wondering if you can help with my little problem. I'm trying to get the user to modify his/her's own details. I'm able to display the whole table of users for the admin to modify but i can't get the user to display just his/her's own details. i'm new to php so i was wonderig if you can look at my code.



<?php

include('config.php');

mysql_select_db("student_bay_co_", $connection);

// query to get records
$query = "Select * from registered_members1 where id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
echo "<table cellpadding=10 border=1>";
echo "<th>Firstnames</th><th>Surname</th><th>Street address</th><th>City</th><th>Postcode</th><th>Phone number</th><th>Email</th><th>Username</th><th>Password</th></tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row["Firstnames"]."</td>";
echo "<td>".$row["Surname"]."</td>";
echo "<td>".$row["Street_address"]."</td>";
echo "<td>".$row["City"]."</td>";
echo "<td>".$row["Postcode"]."</td>";
echo "<td>".$row["Phone_no"]."</td>";
echo "<td>".$row["email"]."</td>";
echo "<td>".$row["Username"]."</td>";
echo "<td>".$row["password"]."</td>";
echo "</tr>";
} //End while
echo "</table>";
//End Else insertion successful
//End else successful Amendment

?>

plahpoy
06 Apr 2011, 11:17 AM
it looks like you are only pulling one record from the db? If so try using mysql_fetch_assoc() which will return a single associative array.

<?php

....db query.....

if(mysql_num_rows($result) > 0){

$array = mysql_fetch_assoc($result);

html.... <?php echo $array['firstnames'];?> ....html

..............