techker Posted August 22, 2014 Share Posted August 22, 2014 (edited) 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 August 22, 2014 by techker Quote Link to comment Share on other sites More sharing options...
techker Posted August 22, 2014 Author Share Posted August 22, 2014 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?? Quote Link to comment Share on other sites More sharing options...
techker Posted August 22, 2014 Author Share Posted August 22, 2014 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 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted August 23, 2014 Share Posted August 23, 2014 while the purpose of your code is to produce client-side html, the issue is the php code and using smarty syntax and commends, which is all php. moving to the php help forum... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.