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" Edited by techker
Link to comment
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??
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.