mySQL PHP dropdown loop

Codes here !

Moderators: egami, macek, gesf

Post Reply
User avatar
TomCornar
New php-forum User
New php-forum User
Posts: 25
Joined: Fri Sep 14, 2012 12:06 am

Tue Sep 18, 2012 5:50 am

hi,

Try this,

Code: Select all

<select name="charname" value="Select" size="1"> 
<?php 

    $sql = "SELECT * FROM characters";  
    $result = mysql_query($sql) or die (mysql_error());  
    while ($row = mysql_fetch_array($result)) 
    { 
            $value=$row["your column name"]; 
            $options.="<OPTION VALUE=\"$value\">".$value; 
    } 
    ?> 
            <option>
            <?php echo $options ?>
            </option>
        </select>
Hope this helps

Regards,
Tom Cornar
Trinay Technology Solutions
http://www.trinay.com

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests