title: php query called in tpl using Smarty
body: <p>Im n00b, so basically i want to call my query which is located in my index.php file from my .tpl file using smarty:</p>
  
  <p><strong>Index.php</strong> </p>
  
  <pre><code>&lt;?php
  
  //Database connection
  $db = mysqli_connect('xx','xx','','xx')
  or die('Error connecting to MySQL server.');
  
  //access Smarty template engine
  require_once('Smarty-3.1.30/libs/Smarty.class.php');
  
  $smarty = new Smarty();
  $smarty-&gt;template_dir = 'views';
  $smarty-&gt;compile_dir = 'tmp';
  
  
  //query product page
  $query = "SELECT * FROM cs_shop";
  mysqli_query($db, $query) or die('Error querying database.');
  
  $result = mysqli_query($db, $query);
  $row = mysqli_fetch_array($result);
  
  
  //query
  while ($row = mysqli_fetch_array($result)) {
  $row['product_category'] . ' ' . $row['product_price'] . ': ' . 
  $row['product_quantity'] . ' ' . $row['product_about'] .' ' 
  .$row['product_color'] .'&lt;br /&gt;';
      }
  
  //db collect data
  $smarty-&gt;assign('row', $row); 
  //template
  $smarty-&gt;display('index.tpl');
  
  mysqli_close($db);
  ?&gt;
  </code></pre>
  
  <p>The while loop i use in the index.php is what i want to call in my .tpl file, im new to smarty and cant get it to work , test database connection and it worked, my , Smarty gets called no errors. </p>
  
  <p>Its a basic static page im just doing experiment, using Smarty, So i just want to display the query as list no td's or anything like that. </p>
  
  <p>So can someone give me a example how my .tpl file would look located in my 'views' directory if i want to display the query?</p>
  
  <p>Thanks in advance</p>