Page 1 of 1

textbox list the data from database

Posted: Sun Apr 12, 2009 10:29 am
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>
 
 
 
 

Re: textbox list the data from database

Posted: Sun Apr 12, 2009 1:28 pm
by php_east
it should be ...
echo '<input type="text" name="username" maxlength="23" value=" '.htmlentities($usernamevalue).'" />';

Re: textbox list the data from database

Posted: Mon Apr 13, 2009 6:06 am
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.

Re: textbox list the data from database

Posted: Mon Apr 13, 2009 6:24 am
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?

Re: textbox list the data from database

Posted: Mon Apr 13, 2009 6:28 am
by susrisha
i beleive you are looking for a <select> tag instead of a text input tag.

Re: textbox list the data from database

Posted: Mon Apr 13, 2009 6:29 am
by susrisha
the select tag code goes like this
<select name="soandso">
<option>abc</option>
<option>def</option>
</select>

Re: textbox list the data from database

Posted: Mon Apr 13, 2009 6:56 am
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.

Re: textbox list the data from database

Posted: Mon Apr 13, 2009 7:00 am
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>
 

Re: textbox list the data from database

Posted: Mon Apr 13, 2009 7:22 am
by angelic_devil
ok i made it as this but now i m getting the drop box thanx

Re: textbox list the data from database

Posted: Mon Apr 13, 2009 9:01 am
by susrisha
wasnt that what you asked for?

Re: textbox list the data from database

Posted: Sun Apr 26, 2009 2:45 am
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

Re: textbox list the data from database

Posted: Sun Apr 26, 2009 11:19 am
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.