Page 1 of 1

Anyone use SMARTY? 2 SQL queries, 1 Smarty.

Posted: Wed Jul 21, 2010 10:51 am
by bla5e
I have 2 PHP-while statements and I am not sure how to put them into a smarty template..

Code: Select all

<?php
  $pubs = pg_query("SELECT * FROM pubs WHERE $musts ORDER BY name");
  while($pub = pg_fetch_assoc($pubs)){
    $query = "SELECT id, keywords, date, content, title, blurb, rank(vector, q), headline(content, q)  FROM {$pub['code']}.articles, to_tsquery('" . str_replace(' ', '&', $phrase) . "') AS q WHERE vector @@ q AND published=true ORDER BY rank(vector, q) DESC";
    $matches = pg_query($db, $query);
    if (pg_num_rows($matches) === 0) {
      echo "none.";
    } else {
       while ($article = pg_fetch_assoc($matches)){
         echo "sql data....";
       }
    }
   }
?> 
I am new to smarty and not sure how to do this.. I will include the current code to help describe, but I have my current page in PHP and need to put it into a smarty template. The PHP has 1 query that runs, then a 'subquery' too and I am not sure how to do this in smarty.. Nothing wrong with my PHP just need help putting it into a smarty template since there is 2 PHP-whiles, not sure how to do it with the smarty-foreach's.