textbox list the data from database

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

Post Reply
angelic_devil
Forum Commoner
Posts: 74
Joined: Thu Apr 02, 2009 7:05 am

textbox list the data from database

Post by angelic_devil »

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
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: textbox list the data from database

Post by php_east »

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

Re: textbox list the data from database

Post by angelic_devil »

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

Re: textbox list the data from database

Post by angelic_devil »

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?
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: textbox list the data from database

Post by susrisha »

i beleive you are looking for a <select> tag instead of a text input tag.
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: textbox list the data from database

Post by susrisha »

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

Re: textbox list the data from database

Post by angelic_devil »

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.
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: textbox list the data from database

Post by susrisha »

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

Re: textbox list the data from database

Post by angelic_devil »

ok i made it as this but now i m getting the drop box thanx
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: textbox list the data from database

Post by susrisha »

wasnt that what you asked for?
angelic_devil
Forum Commoner
Posts: 74
Joined: Thu Apr 02, 2009 7:05 am

Re: textbox list the data from database

Post by angelic_devil »

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
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: textbox list the data from database

Post by McInfo »

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.
Post Reply