View previous topic :: View next topic |
Author |
Message |
ulast Smarty Rookie
Joined: 01 Apr 2013 Posts: 11
|
Posted: Mon Apr 01, 2013 1:17 pm Post subject: display product_id in foreach? |
|
|
sorry my bad english..
i write e-commerce script. but
Code: | {foreach item=cart from=$shopcart}
<tr>
<td>{$cart->product_ID}</td>
</tr>
{/foreach} |
this my shopping cart template. $shopcart is in database shopcart table.
but i use $cart->product_ID and product name id products table ? |
|
Back to top |
|
ulast Smarty Rookie
Joined: 01 Apr 2013 Posts: 11
|
Posted: Mon Apr 01, 2013 2:32 pm Post subject: |
|
|
pls help me |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Apr 01, 2013 6:21 pm Post subject: |
|
|
this isn't part of smarty, sounds like shopping cart software, check their forums? |
|
Back to top |
|
ulast Smarty Rookie
Joined: 01 Apr 2013 Posts: 11
|
Posted: Tue Apr 02, 2013 6:50 am Post subject: |
|
|
mohrt wrote: | this isn't part of smarty, sounds like shopping cart software, check their forums? |
no no this is my script. Im write new script.
and product_ID in cart sql table. product info is product table.
i want use {$cart->product_ID} and product->name in product table??
Code: | {foreach item=cart from=$shopcart}
<tr>
<td>HIDDEN {$cart->product_ID} /HIDDEN {$product->name}</td>
</tr>
{/foreach} |
|
|
Back to top |
|
ulast Smarty Rookie
Joined: 01 Apr 2013 Posts: 11
|
Posted: Tue Apr 02, 2013 6:57 am Post subject: |
|
|
Code: | $carts = $db->get_results("SELECT * FROM carts");
foreach ($carts AS $cart){
$product = $db->get_row("SELECT * FROM products WHERE id='$cart->product_ID'");
echo $product->name;
} |
i want this in smarty! |
|
Back to top |
|
ulast Smarty Rookie
Joined: 01 Apr 2013 Posts: 11
|
Posted: Thu Apr 04, 2013 6:37 am Post subject: |
|
|
help me pls.. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Apr 04, 2013 1:59 pm Post subject: |
|
|
Code: | $carts = $db->get_results("SELECT * FROM carts");
foreach ($carts AS $idx=>$cart){
$carts[$idx]->product = $db->get_row("SELECT * FROM products WHERE id='{$cart->product_ID}'");
}
$smarty->assign('carts',$carts); |
Code: | {foreach item=cart from=$carts}
{$cart->product_ID}
{$cart->product->name}
{/foreach} |
|
|
Back to top |
|
ulast Smarty Rookie
Joined: 01 Apr 2013 Posts: 11
|
Posted: Thu Apr 04, 2013 4:52 pm Post subject: |
|
|
yesss!! thank you my friend! |
|
Back to top |
|
|