PDA

View Full Version : [PHP] How



Jibbish
23-03-2008, 08:11 PM
Ok, say like I had a form for editing users. And there is a select drop down menu to select a user to edit. When I select the username, I want the current username to automaticlly filled in, on the new username input box if you get what I mean how do you do it?

Moved by Hitman (Forum Moderator) from Designing & Development: Please post in the correct forum next time, thanks. :)

Hypertext
23-03-2008, 08:18 PM
dynamically get which is on, if it is on that one echo selected eg something like..

<select name="x" id="x">
<option value="olduser" <?php if($user == "old user") { echo " selected "; }>old user</option>
<option value="olduser" <?php if($user == "new user") { echo " selected "; }>new user</option>

Independent
24-03-2008, 08:12 AM
dynamically get which is on, if it is on that one echo selected eg something like..

<select name="x" id="x">
<option value="olduser" <?php if($user == "old user") { echo " selected "; }>old user</option>
<option value="olduser" <?php if($user == "new user") { echo " selected "; }>new user</option>

If you're using MySQL use the one below, I grabbed it from housekeeping Version one (: [Change the database things and config file, or edit it tottaly)

<?
echo "<select size='1' name='username_post'>
<option selected>Choose Your Name</option>";
include('dbConfig.php');
$result = mysql_query("SELECT * FROM `staff`");
while($worked = mysql_fetch_array($result)) {
$username = $worked["username"];
echo "<option value=$username>$username</option>";
}
mysql_close(); ?>

Want to hide these adverts? Register an account for free!