Link to home
Start Free TrialLog in
Avatar of fasuln
fasulnFlag for Ireland

asked on

PHP Dropdown Question

Hi there,

I am new to php and so I am having an issue with drop. I want my dropdown to display firstname and lastname together, but I am not sure how.

Here is my query at present:
=================================================================
<?php
                                    
                                    $query1 = "select firstname, lastname from staff ";                                    
                                    mssql_query($query1) or die('Error, query failed');            
                                    $result1 = mssql_query($query1);
                                    
                                    
                                    while($row1 = mssql_fetch_array($result1))
                                    {
                              ?>
                        <option value="<?php echo $row1['firstname'];?>"><?php echo $row1['firstname'];?>                        </option>
                 
                        <?php }?>
======================================================================


Any idea?

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fasuln

ASKER

Hi there,

You query will still only show 'firstname'.

Please advise.

Thanks,
<?php
                                   
                                    $query1 = "select firstname, lastname from staff ";                                    
                                    mssql_query($query1) or die('Error, query failed');            
                                    $result1 = mssql_query($query1);
                                   
                                   
                                    while($row1 = mssql_fetch_array($result1))
                                    {
                              ?>
                        <option value="<?php echo $row1['firstname']. ' ' . $row1['lastname'];?>">                      </option>
                 
                        <?php }?>
Avatar of fasuln

ASKER

I replaced your code with mine and I am only displaying blanks now. User generated image
<option value="<?php echo $row1['firstname']. ' ' . $row1['lastname'];?>">
<?php echo $row1['firstname']. ' ' . $row1['lastname'];?>
</option>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial