Jump to content

smarty template fetch..


techker

Recommended Posts

hey guys i have this code to grab info from database in my inv.php file

$dbConn = new DBConnection();
$i = new dbHandler($dbConn, 'inventory');
 
$inv = array();
 
$sel=mysql_query("select * from inventory");
while($row=mysql_fetch_array($sel)) {
   $inv[] = $row;
}
 
$smarty->assign('inventory', $inv);
 
 
// Finally, display the actual page
$smarty->display('InvViewAdd.tpl');

How to i make it show the info on my InvViewAdd .tpl page?

 

also if i put

$inv = $i->showInv();
$smarty->assign('inv', $inv);
 
from my class page:
 
public function showInv()
    {
        $dbConn = new DBConnection();
        $i = new dbHandler($dbConn, 'inventory');
 
$inv = $i->getResultsWhere('order by itemCode DESC LIMIT 0, 1 ');
        
       
        return $inv;
    }
 
 
i get this,i see it works but can't output
 
{foreach from=$inv item=itemCode}
                    <tr class="responsive">
                        <td class="responsive">{$inv[0]}</td>
                        <td class="responsive">$inventory</td>
                        <td class="responsive">{$inv->date|date_format}</td>
                        <td class="responsive">${$rows_returned}</td>
                        <td class="responsive">
 

 

 

 

$SCRIPT_NAME Smarty_Variable Object (3)
->value = "/TEST/Inv.php"
->nocache = false
->scope = "file:InvViewAdd.tpl" $inv Smarty_Variable Object (3)
->value = Array (1)
  0 => stdClass Object (7)
     ->id = "13"
     ->itemCode = "299945844554"
     ->qtyOnHand = "5"
     ->itemDesc = "kenwood DDH-5342"
     ->itemPrice = "299.99"
     ->itemRetail = "599.99"
     ->itemWholesale = ""
->nocache = false
->scope = "file:InvViewAdd.tpl" $smarty Smarty_Variable Object (3)
->value = null
->nocache = false
->scope = "file:InvViewAdd.tpl"
Link to comment
https://forums.phpfreaks.com/topic/290597-smarty-template-fetch/
Share on other sites

ok so with the second code i figured out part

 

{foreach from=$inv item=itemCode}
                    <tr class="responsive">
                        <td class="responsive">{$itemCode->itemCode}</td>
                        <td class="responsive"></td>
                        <td class="responsive">{$inv->date|date_format}</td>
                        <td class="responsive">${$rows_returned}</td>
                        <td class="responsive">
 
works but i only get one how can i show all??

lol i settle it..uhh but still don't understand all of it..

 

$inv = $i->getResultsWhere('order by itemCode DESC LIMIT 0, 1 ');

 

changed the limit...

 

{foreach from=$inv item=itemCode}

 <td class="responsive">{$itemCode->itemCode}</td>
<td class="responsive">{$itemCode->itemDesc}</td>
 <td class="responsive">{$itemCode->qtyOnHand}</td>
<td class="responsive">${$itemCode->itemRetail}</td>
 
this?
 
if im correct from $inv is the query the you associate it to item that becomes $itemcode

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.