phpli连接一个表,让他安不同的方循环出来
php文件
$sql = "SELECT * FROM `pp_vod` where vod_cid = 8 order by vod_addtime LIMIT 0 , 12";
$query = mysql_query($sql);
$i = mysql_num_rows($query);
$j = 0;
while($a = mysql_fetch_array($query)){
if ( $j
$id[$j] = $a['vod_id'];
$area[$j] = $a['vod_area'];
$hits[$j] = $a['vod_hits'];
$title[$j] = $a['vod_name'];
$author[$j] = $a['vod_actor'];
$authoreml[$j] = $a['authoreml'];
$putdate[$j] = $a['vod_addtime'];
$pic[$j] = $a['vod_pic'];
$cat[$j] = $a['vod_cid'];
$content[$j] = $a['vod_content'];
$j++;
}
}
$t->set_file("main","3333.htm");
$t -> set_block("main","row","rows");
for($j = 0; $j $t -> set_var(array("authoreml" => $authoreml[$j],
"author" => $author[$j],
"id" => $id[$j],
"title" => $title[$j],
"putdate" => $putdate[$j],
"pic" =>$pic[$j]));
$t -> parse("rows","row",ture);
}
$t->parse("out","main",true);
/*
此方法共有三个参数,目前我们先只用前两个.第一个参数为一会要输出的名称,第二个参数为之前定义模板文件时的名称.
*/
//输出
$t->p("out");
模板文件