PHP查询选项定义中的PHP下拉框

I have been trying to decipher the option part of this: echo "<option value='" . $row['PcID'] . "'>" . $row['PcID'] . "</option>"; taken from Populate a Drop down box.....

can someone kindly explain what the periods do? and why when i do this: print "<option value='".$wrow['week_num']."'>".$wrow['week_name']."</option><br> "; I only get only the week name in the list.

$wquery="select week_num,week_name from stats_week";
$wresult=mysql_query($wquery);
print "Select Week:<select name=Week_select><br>
";
while ($wrow=mysql_fetch_assoc($wresult)){
    print "<option value='".$wrow['week_num']."'>".$wrow['week_name']."</option><br>
";    
}
print "</select>";

In PHP, the period is the concatentation operator. Putting the periods in tells PHP to concatenate strings, See this page:

http://www.php.net/manual/en/language.operators.string.php

The periods "break up" the string, and allow you to run PHP code (mainly variables/ternary operators/functions) in it's place, between them.

It's also a method of joining strings. This is called Concatenation.

See String Operators


Also, you only see the week name in the list because that's the only output you've got between your <option></option> tags.

Does this help,

$wquery="select week_num,week_name from stats_week";
$wresult=mysql_query($wquery);
print "Select Week:<select name=Week_select>";
while ($wrow=mysql_fetch_assoc($wresult)){
    print "<option value='".$wrow['week_num']."'>".$wrow['week_num']." - ".$wrow['week_name']."</option>
";    
}
print "</select>";

This will display the week number and name in the list. I've also removed the <br /> tags after your select/options.

Please familiarise yourself with HTML Selects/Options.

Replace with;

print "<option value='{$wrow['week_num']}'>{$wrow['week_name']}</option><br>
";  

This will print the correct values and not return the php in html

You will also want to look at concatenation on the PHP documentation