Php Error on Displaying Third row
<option value='$row2['cID']'>".$row2['prefix']."
Throws an error:
开发者_Go百科syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
This code works fine:
<option>".$row2['prefix']." "."</option><br />
How can I add the cID in?
Thanks
Fix your quoting
"<option value='" . $row2['cID'] . "'>".$row2['prefix']."
Or better: enclose the whole thing in double-quotes and enclose the array elements in {}
"<option value='{$row2['cID']}'>{$row2['prefix']}</option>"
Try :
$foo = "<option value='".$row2['cID']."'>".$row2['prefix']."";
You can't use the single quotes for the "value"
use:
"<option value='" . $row2['cID'] . "'>" . $row2['prefix'] . "</option>"
$cID = $row2['cID'];
$prefix = $row2['prefix'];
echo <<< EOF
<option value="$cID">$prefix</option><br />
EOF;
精彩评论