Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to edit the user information by admin
    text
    copied!<p>I am developing my first simple website using PHP. Now, I am working in the admin page and I want to let him adding, deleting users and editing the personal information of the existed users. I did the adding and deleting. Now, I want to develop editing users. First of all, I want him to choose the user from drop list, then fetch the user information automatically after choosing him from the drop list, and after that editing his information. So how can I do that?</p> <p>My code:</p> <pre><code>&lt;?php ob_start(); $host="localhost"; // Host name $username="root"; // Mysql username $password="13524"; // Mysql password $db_name="sharingi_db"; // Database name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); ?&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;script language="javascript"&gt; function reload(form){ var val=form.username.options[form.username.options.selectedIndex].value; self.location='editUser2.php?username=' + val ; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content_main" class="admin_student_height"&gt; &lt;!-- Here starts the first form --&gt; &lt;form method="get"&gt; &lt;h3&gt;Choose A User&lt;/h3&gt; &lt;br /&gt; select name="username" onchange="reload(this.form)"&gt; &lt;option&gt; &lt;?php if(isset($_GET['username'])) echo "{$_GET['username']}"; else echo "Select one"; ?&gt; &lt;/option&gt; &lt;?php if(isset($_GET['username'])){ $exceptcc = $_GET['username']; $sql = "SELECT username FROM user WHERE user.username NOT IN ('$exceptcc')"; } else $sql = "SELECT username FROM user"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo "&lt;option value={$row['username']}&gt;{$row['username']}&lt;/option&gt;"; } ?&gt; &lt;/select&gt;&lt;br /&gt;&lt;br /&gt; &lt;h3&gt;User Information&lt;/h3&gt; &lt;br /&gt; &lt;?php $thecc = $_GET['username']; $sql = "SELECT Firstname FROM user WHERE Username=$thecc"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo "{$row['Firstname']}&gt;{$row['Firstname']}}"; } ?&gt; &lt;br /&gt;&lt;br /&gt; &lt;/form&gt; &lt;br /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload