テンプレートのドロップダウン ボックスに入力しない賢いプラグインがあります。
これは私の function_candidates.php コードです:
<?php
function smarty_function_candidates(array $parameters, Smarty_Internal_Template $smarty)
{
$sql = "SELECT first_name, last_name, id, candidate FROM wmmw.main_members WHERE candidate='1'";
$result = mysql_query($sql)
or die("Couldn't execute user query.");
foreach ($result as $row){
$candidates[] = array(
"fname" => $row["first_name"],
"lname" => $row["last_name"],
"id" => $row["id"],
"candidate" => $row["candidate"]);
}
$smarty->assign("candidates", $candidates);
}
?>
これは私のテンプレートコードです:
<section>
{candidates}
<label for="candidate">Candidate</label>
<div>
<select name="candidate" id="candidate">
<optgroup label="candidate">
{foreach item=c from=$candidates}
<option name="candidate" value="{$c.fname}">{$c.fname}</option>
{/foreach}
</optgroup>
</select>
</div>
</section>
ドロップダウン ボックスが表示されますが、値は書き込まれません。ここで何が欠けていますか?助けていただければ幸いです...
送信