- 论坛徽章:
- 0
|
谢谢各位!
我想让程序显示出我在MYSQL里取得的数据。
index.php块循环片段
[php]
//***************************************交易历史*****************************
$tpl->set_block("tmp_index", "trade_history_row", "trade_history_rows"); //第一层
$tpl->set_block("trade_history_row", "trade_history_list", "trade_history_lists"); //第二层
$query = "select type,game_name,game_server,game_ID,role_name,state,date from trade_history where from_user = '".$_COOKIE["member_user"]."'";
$tmp_query = mysql_query($query);
$tmp_query_data_count =mysql_query("SELECT COUNT(id) FROM trade_history where from_user = '".$_COOKIE["member_user"]."'"); //统计 数据 的 行数 (也就是有多少条数据)
$query_array_data_count = mysql_fetch_array($tmp_query_data_count); //取出 条数
$data_count = $query_array_data_count[0];
for($i=0;$i<$data_count;$i++) //循环 <tr> 第一层块
{
$tpl->set_var("trade_history_rows");
for($j=0;$j<$data_count;$j++) // 第二层块
{
$query_array = mysql_fetch_array($tmp_query);
$tpl->set_var("type", $query_array["type"]); //交易类型
$tpl->set_var("game_name", $query_array["game_name"]); //游戏名称
$tpl->set_var("game_server", $query_array["game_server"]); //服务器名称
$tpl->set_var("game_ID", $query_array["game_ID"]); //游戏ID
$tpl->set_var("role_name", $query_array["role_name"]); //角色名称
$tpl->set_var("state", $query_array["state"]); //状态
$tpl->set_var("date", $query_array["date"]); //记录生成时间
$tpl->parse("trade_history_rows", "trade_history_row", true);
}
$tpl->parse("trade_history_lists", "trade_history_list", true);
}
//***************************************交易历史*****************************
[/php]
===================================
index.html块循环 代码片段
<!-- BEGIN trade_history_row -->
<tr>
<!-- BEGIN trade_history_list -->
<td align="center">{type}</td>
<td align="center">{game_name}</td>
<td align="center">{game_server}</td>
<td align="center">{game_ID}</td>
<td align="center">{role_name}</td>
<td align="center">{state}</td>
<td align="center">{date}</td>
<!-- END trade_history_list -->
</tr>
<!-- END trade_history_row -->
==================================
现在出现的效果:
但是MYSQL中有两条数据:
如何让它正常显示呢?
$tpl->set_var("...","...");
这我也已经用了循环 嵌套,但总是最后,我也想用类型 $query_array["type"][$j],但显示出来是个问号。
谢谢各位了!在线等,很急。
[ 本帖最后由 漫无目的 于 2007-7-31 11:04 编辑 ] |
|