How to get the data out of OBD into smarty



  • How do you get the data. I did this: index.php

    https://pastebin.com/cXbMR4Ng

    index.tpl:

    https://pastebin.com/G5DhydpU

    But smarty makes a mistake: Notice: Undefined index: rw in C:\web\templates_c\d376f5d67a0ec32ce4f73820d1aba109b1d04078_ 0.file.index.tpl.php on line 32

    Notice: Trying to get property 'value' of non-object in C:\web\templates_c\d376f5d67a0ec32ce4f73820d1aba109b1d04078_ 0.file.index.tpl.php on line 32 32 Please help me.



  • Do you have an ancient martyr of the second version?

    Method https://www.smarty.net/docsv2/ru/api.assign.tpl Adopts two arguments, a name and meaning, or an association, not just a bunch of arguments like you.

    transfer the entire data set to the template

    $st = $db->query("select field1, field2...");  // не надо использовать звездочку
    $data = $st->fetchAll('assoc');                // получите сразу весь массив
    

    $smarty->assign('data', $data);
    $smarty->assign('title', "main page");

    in the template, write the mass cycle.

    <ul>
    {foreach $data as $d}
    <li>{$data.name} ....</li>
    {/foreach}
    </ul>



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2