We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

PHP Dropdown Question

fasuln
fasuln asked
on
Medium Priority
307 Views
Last Modified: 2012-05-11
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,
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Hi there,

You query will still only show 'firstname'.

Please advise.

Thanks,
CERTIFIED EXPERT

Commented:
<?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 }?>

Author

Commented:
I replaced your code with mine and I am only displaying blanks now. drop
<option value="<?php echo $row1['firstname']. ' ' . $row1['lastname'];?>">
<?php echo $row1['firstname']. ' ' . $row1['lastname'];?>
</option>
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.