dqr3883 2013-12-01 20:27
浏览 51

如何在smarty中访问php while循环变量

I have completed a php page with my poor logic but working fine... i want to access data of that page into smarty page. Page name id dealers.php and theme page name is dealers.html

I want to access while loop data into smarty

$q1=mysql_query("select * from class_users where active=1 and store=1 ORDER BY rand() limit 8");

while ($ev= mysql_fetch_object($q1)){
$did = "$ev->id";
$dname = "$ev->contact_name";
$drating     = "$ev->rating";
$rating = round($drating);
$dnorating = "$ev->no_ratings";
$dphoto  = "$ev->photo";
$dc  = "$ev->company_name";
$store_banner    = "$ev->store_banner";
$durl = preg_replace('~[^A-Za-zds-]+~u', '',  strtolower($dname));

it mean i am storing data from database in variables... so i want to use this variables into smarty template file. How to assign while loop and how to get while loop variables in smarty ...?

dealer.php $smarty->assign(dealer_name, $dname);

dealers.html {$dealer_name}

It showing only one name one time. Need to get all dealers from database using above php logic. Just tell me how to assccess these variables in dealers.html

  • 写回答



      相关推荐 更多相似问题


      • ¥15 将字符串形式的数组转化
      • ¥15 执行import paddle代码出现错误如何解决?
      • ¥15 hisat2align exited with value 137
      • ¥15 寻找大学生合作开发软件(Delphi)
      • ¥30 AndroidBench&eMMC内存测试速度&Android
      • ¥15 W10 文件共享失败 怎么解决
      • ¥20 b站私信完整导出的方法
      • ¥15 边界图中的x、y轴解释
      • ¥30 如何用matlab求解复杂方程
      • ¥15 VUE TS中怎么调用第三方js