Editing a User's details

Kindly assist me with situation below:

I am able to view my registered user. I have written a script to allow a particular user to be edited. This script pulls the user information from the database and displays it the same way as when the user was being registered. However, there are 2 drop-down areas and 1 radio button area. My problem is displaying the information in these areas so that if not edited, they remain the same. Otherwise I have to re-select these options and editing succeeds.

Code snippet is below:
[php]// Retrieve the user’s information:
$q = “SELECT user_name, first_name, last_name, email, position, dept, user_level FROM users WHERE user_id=$id”;
$r = mysqli_query ($dbc, $q);

//$dbc is my database connection parameters
if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form.

// Get the user’s information:
$row = mysqli_fetch_array ($r, MYSQLI_NUM);
// Create the form:
echo ’





 <tr><td>Department:</td><td><select name="dept"/>
Management Administration Logistics Fleet IT
User Name:
Surname:
Last Name:
Email Address:
Position: Director Finance/Administration Manager Logistics/Procurement Manager Store Manager Fleet Manager IT Manager Receptionist
User Level Admin
<input type="radio" name="usrlevel" value="' . $row[6] . '" User
 
 
 
';[/php]

Any help is appreciated.

Regards,

I couldn’t test it, but it should work.

[php]// Retrieve the user’s information:
$q = “SELECT user_name, first_name, last_name, email, position, dept, user_level FROM users WHERE user_id=$id”;
$r = mysqli_query ($dbc, $q);

//$dbc is my database connection parameters
if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form.

// Get the user’s information:
$row = mysqli_fetch_array ($r, MYSQLI_NUM);
// Create the form:
echo ’





 <tr><td>Department:</td><td><select name="dept"/>
' . $row[5] . ' Management Administration Logistics Fleet IT
User Name:
Surname:
Last Name:
Email Address:
Position: ' . $row[4] . ' Director Finance/Administration Manager Logistics/Procurement Manager Store Manager Fleet Manager IT Manager Receptionist
User Level '; if($row[6] == 'Admin'){ echo('Admin
'){ }else{ echo('Admin
'); } if($row[6] == 'User'){ echo('User
'){ }else{ echo('User
'); } echo('
 
 
 
';[/php]

Take a look at it, change any values which are wrong, like Admin instead of admin etc.

Thanks Lothop…

It works perfectlly after editing some parts like the () surrounding the echo statements and the rest as you suggested…

Kudos… Kudos…

Opps, lol, missed it out. My bad.

Glad its working for you.

Sponsor our Newsletter | Privacy Policy | Terms of Service