How to add second variable to a variable in a dropdown using PHP?
I have an HTML select element created in PHP. I want to add $car (a second variable) with the $person_name. So it should $car and $person_name. how can i do it to the snippet below:
echo "<option val开发者_开发百科ue=\"".$person_id."\">".$person_name."</option>";
echo "<option value=\"".$person_id."\">" . $car . " - " . $person_name."</option>";
This will cause the display value in the drop-down to show (if $car = "Chevy" and $person_name = "Fosco"): "Chevy - Fosco"
I think you means add another variable.
Example 1:
echo "<option value=\"".$person_id."\">".$person_name.$car."</option>";
Example 2:
echo "<option value=\"".$person_id."\">".$person_name.' '.$car."</option>";
echo "<option value='$person_id $car'>$person_name $car</option>";
精彩评论