Link to home
Start Free TrialLog in
Avatar of jcbodyworks
jcbodyworks

asked on

PHP While Loop drop down menu problem

I have this problem with a while loop that keeps returning the first initial of someone's name when it runs. I want the full name. The loop is designed to create a drop down list that works fine, except for this stupid inconsistency. I checked the database, and the full name is definitely there. The last name comes out fine, so I dont know where the problem is. Here is the code:

$resulttwo=mysql_query("SELECT * FROM employees WHERE empnum>=1 ORDER BY firstname ASC") or die(mysql_error());

$displayth ='<select name="th" id="th">';

$p=0;

while ($rowtwo=mysql_fetch_array($resulttwo))
{
$empid[$p]=$rowtwo['employeeid'];
$firstname[$p]=$rowtwo['firstname'];
$lastname[$p]=$rowtwo['lastname'];
$displayth .='<option value="' . $empid[$p] . '">' . $firstname[$p] . " " . $lastname[$p] . '</option>';
$displayth .= '</font><font size="2" face="Eras Demi ITC">';


$p++;
}
$displayth .='</select>';

echo $displayth;
ASKER CERTIFIED SOLUTION
Avatar of MasonWolf
MasonWolf
Flag of United States of America 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 jcbodyworks
jcbodyworks

ASKER

I just looked through the entire code of my site, turns out I have another variable like this:

$firstname=$_SESSION['firstname'];

this was causing the problem. I changed the variable, so now everything works like a charm! Thank you!
Hey, good job! Thanks for the points, and good luck.