PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
angelic_devil
Forum Commoner
Posts: 74 Joined: Thu Apr 02, 2009 7:05 am
Post
by angelic_devil » Sun Apr 12, 2009 10:29 am
i want the text field to list the data from the column called username from the database ....but the textbox is not listing anything below is the code...plz tell me where i m going wrong.
Code: Select all
<body>
<?php
$username = 'username';
$usernamevalue = array();
$i=0;
$query_name = "SELECT users.username FROM users ";
$result = mysql_query($query_name);
confirm_query($result);
while ($record = mysql_fetch_assoc($result)) {
while (list($username, $usernamevalue) = each ($record)) {
//echo $username.": <B>".$usernamevalue."</B><BR>";
echo <input type="text" name="username" maxlength="23" value=" htmlentities($usernamevalue)" />;
}
echo "<BR>";
}
?>
<form action="admin_account.php" method="post">
<div style="position: absolute; width: 100px; height: 32px; z-index: 1; left: 225px; top: 35px" id="layer2">
<td><input type="text" name="username" maxlength="23" value="<?php echo htmlentities($usernamevalue); ?>" /></td>
</div>
</form>
</body>
Last edited by
Benjamin on Sun Apr 26, 2009 12:01 pm, edited 1 time in total.
Reason: Changed code type from text to php
php_east
Forum Contributor
Posts: 453 Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.
Post
by php_east » Sun Apr 12, 2009 1:28 pm
it should be ...
echo ' <input type="text" name="username" maxlength="23" value=" ' .htmlentities($usernamevalue).' " />' ;
angelic_devil
Forum Commoner
Posts: 74 Joined: Thu Apr 02, 2009 7:05 am
Post
by angelic_devil » Mon Apr 13, 2009 6:06 am
ok now its displaying the data but its not listing it in a drop down box instead showing separate text items..i want it in a drop down box....With scroll options like alistbox or dropbox has.
angelic_devil
Forum Commoner
Posts: 74 Joined: Thu Apr 02, 2009 7:05 am
Post
by angelic_devil » Mon Apr 13, 2009 6:24 am
i made a few changes to the code now i m getting them to list the data but its still not showing me the scroll icons for the drop box how can i get tht?
susrisha
Forum Contributor
Posts: 439 Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India
Post
by susrisha » Mon Apr 13, 2009 6:28 am
i beleive you are looking for a <select> tag instead of a text input tag.
susrisha
Forum Contributor
Posts: 439 Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India
Post
by susrisha » Mon Apr 13, 2009 6:29 am
the select tag code goes like this
<select name="soandso">
<option>abc</option>
<option>def</option>
</select>
angelic_devil
Forum Commoner
Posts: 74 Joined: Thu Apr 02, 2009 7:05 am
Post
by angelic_devil » Mon Apr 13, 2009 6:56 am
in select tag wont i have to input each data manually...i want the field to list the data from the database based on the condition. will it do tht?
if yes cud u type the syntax for tht plz.
susrisha
Forum Contributor
Posts: 439 Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India
Post
by susrisha » Mon Apr 13, 2009 7:00 am
Code: Select all
<select name="username">
<?php
while (list($username, $usernamevalue) = each ($record)) {
//echo $username.": <B>".$usernamevalue."</B><BR>";
// echo <input type="text" name="username" maxlength="23" value=" htmlentities($usernamevalue)" />;
echo '<option>'.htmlentities($usernamevalue).'</option>';
}
?>
</select>
angelic_devil
Forum Commoner
Posts: 74 Joined: Thu Apr 02, 2009 7:05 am
Post
by angelic_devil » Mon Apr 13, 2009 7:22 am
ok i made it as this but now i m getting the drop box thanx
susrisha
Forum Contributor
Posts: 439 Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India
Post
by susrisha » Mon Apr 13, 2009 9:01 am
wasnt that what you asked for?
angelic_devil
Forum Commoner
Posts: 74 Joined: Thu Apr 02, 2009 7:05 am
Post
by angelic_devil » Sun Apr 26, 2009 2:45 am
oops didnt realize only oart of the message was posted... i meant i m getting a drop down box thanx.... but is there a way to get listbox the with scrollbars
McInfo
DevNet Resident
Posts: 1532 Joined: Wed Apr 01, 2009 1:31 pm
Post
by McInfo » Sun Apr 26, 2009 11:19 am
Code: Select all
<select multiple="multiple">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
Edit: This post was recovered from search engine cache.