$phplib->set_block("center","recordelist","a");$sql="select * from table";
$query=mysql_query($sql);
while ($row=mysql_fetch_array($query)){
$phplib->set_var("rowid",$row["field"]);
}
$phplib->parse("a","recordelist",true);其中center是你的要用到block的模板
然后在模板center中
<select name=select1>
<!-- recordelist BEGIN -->
<option value="{rowid}">{rowid}</option>
<!-- recordelist END -->
</select>
好象是这样,蛮以前用过
$query=mysql_query($sql);
while ($row=mysql_fetch_array($query)){
$phplib->set_var("rowid",$row["field"]);
}
$phplib->parse("a","recordelist",true);其中center是你的要用到block的模板
然后在模板center中
<select name=select1>
<!-- recordelist BEGIN -->
<option value="{rowid}">{rowid}</option>
<!-- recordelist END -->
</select>
好象是这样,蛮以前用过
<select name="Type">
<!-- BEGIN Type -->
<option {checked}>{TypeName}</option>
<!-- END Type -->
</select>程序文件中:
$result = mysql_query($sql);
$template->set_bloc("handle", "Type", "block");
while($row = mysql_fetch_array($rsult))
{
$name = $row["name"];
$template->set_var("TypeName", $name);
$template->parse("block1", "Type", true);
}
mysql_free_result($result);
怎么回事啊,下面是我的代码:
$edit = $_GET['edit'];//下拉选框开始$sql = "select * from sp1_sort";
$db->query($sql);$template->set_block("msgedit","Type","block");while ($db->next_record()) {
$template->set_var("sort_name",$db->f("msg_sort_name"));
$template->set_var("sort_id",$db->f("msg_sort_id"));
$template->parse("block","Type",true);
}//下拉选框结束if ($edit==0) {
$commend = "";
$hide = "";
$content = "";
$template->set_var( array(
"commend" => $commend,
"hide" => $hide,
"msg_content" => $content
)
);
} else {
$sql = "select * from $tbl where msg_id=$edit";
$db->query($sql);
$db->next_record();
if ($db->f("msg_commend")=='0') $commend_n = "checked";
else $commend_n = "";
if ($db->f("msg_commend")=='1') $commend_y = "checked";
else $commend_y = "";
if ($db->f("msg_hide")=='1') $hide_n = "checked";
else $hide_n = "";
if ($db->f("msg_hide")=='0') $hide_y = "checked";
else $hide_y = "";
$template->set_var( array(
"commend_n" => $commend_n,
"commend_y" => $commend_y,
"hide_n" => $hide_n,
"hide_y" => $hide_y,
"msg_content" => $db->f("msg_content")
)
);
}
$template->parse("out", "msgedit");
$template->p("out");除了下拉选框不能显示数据,别的都可以正常显示,不是问题出在哪里。请高手指点一下,谢谢!!
option selected value="">请选择...</option>
<!-- BEGIN Type -->
<option selected value="{sort_id}">{sort_name}</option>
<!-- END Type -->
</select>
<table width="611" align="center" cellspacing="1" bgcolor="#FFCCFF">
<tr>
<td width="94" bgcolor="#F5F5F5"> <div align="right">所属类别:</div></td>
<td width="504" bgcolor="#FFFFFF"> <select name=Type id="Type">
<option selected value="">请选择...</option>
<!-- BEGIN Type -->
<option value="{sort_id}">{sort_name}</option>
<!-- END Type -->
</select></td>
</tr>
<tr>
<td bgcolor="#F5F5F5"> <div align="right">是否推荐:</div></td>
<td bgcolor="#FFFFFF"> 不推荐
<input type="radio" name="commend" value="0" {commend_n}>
推荐
<input type="radio" name="commend" value="1" {commend_y}></td>
</tr>
<tr>
<td bgcolor="#F5F5F5"><div align="right">是否显示:</div></td>
<td bgcolor="#FFFFFF">要显示
<input name="hide" type="radio" value="0" {hide_y}>
隐藏
<input type="radio" name="hide" value="1" {hide_n}></td>
</tr>
<tr>
<td bgcolor="#F5F5F5"><div align="right">短信内容:</div></td>
<td bgcolor="#FFFFFF"><textarea name="content" cols="70" rows="5" id="content">{msg_content}</textarea></td>
</tr>
<tr>
<td bgcolor="#F5F5F5"> </td>
<td bgcolor="#FFFFFF"> <input type="hidden" name="id" value="{msg_id}">
<input type="submit" name="Submit" value="提交"> <input type="button" onClick="history.back();" value="取消"></td>
</tr>
</table>
</form>
模板部分:
option selected value="">请选择...</option>
<!-- BEGIN Type -->
<option {sort_id}>{sort_name}</option>
<!-- END Type -->
</select>
按照你的改了还是没有显示。
<html>
<head>
<script>
function init ()
{
document.form1.types.value = '{types_show}';
}
</script>
</head>
<body onLoad="init();">
<form name="form1">
<select name="types">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
</form>
</body>php<?php
$tpl->set_var ('types_show', 'a');// 这里的a其实就是你从数据库中取出的值?>