<?php
include("dbconnect.php");
$sql="select * from moon";
$arr = array();
$i=0;
$result=mysql_query($sql,$con);
while($row=mysql_fetch_array($result))
{
//print_r($row);
$arr[$i]=$row;
$i++;
}
//print_r($arr);


require 'smarty.php';
$smarty->assign('arr',$arr);
$smarty->display('index.htm');
?>

可以不用FOR徇环

//////////////////////////////////////////////////////////////////////////////////////////

$smarty->assign('counts', 5);

{section name=loop loop=$counts}
id: {$smarty.section.loop.index}
{/section}

输出:id: 0 id: 1 id: 2 id: 3 id: 4

相关文章:

  • 2021-12-23
  • 2021-10-10
  • 2021-05-08
  • 2021-06-03
  • 2022-02-07
  • 2021-10-14
猜你喜欢
  • 2021-12-23
  • 2021-12-23
  • 2021-05-12
  • 2022-12-23
  • 2021-12-03
  • 2022-01-02
  • 2021-12-03
相关资源
相似解决方案