[B]Hi Friends,
I have some data from database Table which must be display as output . I assign the array in PHP page to smarty template…
The array structure I plan to assign to smarty is :
Array ( [publisher] => Array ( [0] => pen books [1] => pen books [2] => Jacks books [3] => May books [4] => Ram books ) [title] => Array ( [0] => For Earners [1] => Bol in glance2 [2] => Dummy For Earners [3] => Bol in glance2 [4] => New man ) [isbn] => Array ( [0] => 8709873689098 [1] => 5495736309876 [2] => 9789873689093 [3] => 9785495789760 [4] => 9781119087441 ) )
I need to get the display output in HTML as :
display output
publisher title isbn
===== === =======
pen books For Earners 8709873689098
jacks books Bol in glance2 5495736309876
May books Dummy For Earners 9789873689093
Ram books New man 9781119087441
Please give a method to do the things in smarty. I need a solution using foreach or section or both in smarty . Please Give a method to accomplish same in smarty …
Thanks in Advance …
Regards
Anes P.A [/B]
[B]Hi Friend,
Any way I take the solution in some other way.
Friend I have a Doubt Regarding Queries, that means
I have a Table named : TEST in mysql.
it has some fields like : mobi_deleted,pub_deleted,pdf_deleted …
according to operation any one of field is updated …
in my php i got a variable , $var , it’s value may be mobi, pub or pdf…
Do I can Write a query like:
UPDATE TEST SET {$var}_deleted = 0;
is this Work properly… Waiting for ur valuable Reply…
Bye Anes
[/B]
Common, you also try something. Did you try to read the examples in the URL given in my last post?
Did you try something?
$books = array ('publisher' => array ('pen books','pen books', 'Jacks books', 'May books', 'Ram books'),
'title' => array ('For Earners', 'Bol in glance2', 'Dummy For Earners', 'Bol in glance2', 'New man'),
'isbn' => array (8709873689098, 5495736309876,9789873689093,9785495789760,9781119087441)
);
$smarty->assign('books', $books);
And in smarty template:
{$books.publisher[0]}<br />
{$books.title[0]}<br />
{$books.isbn[0]}<br />
Hope this works.
And for the loop, try to see the manual here:
[B]Hi Friend,
Thanks For your Reply. I done as you specified here , But Please Look the array Structure
I given in the Question . I need to change Array structure as u direct , but I seek a solution
with that array without any change in it’s structure.
Thanks For your Reply any way, if you can find a way in this Array structure it’s a nice
thing…
[/B]
$smarty->assign('Contacts',
array('fax' => '555-222-9876',
'email' => 'zaphod@slartibartfast.example.com',
'phone' => array('home' => '555-444-3333',
'cell' => '555-111-1234')
)
);
$smarty->display('index.tpl');
{$Contacts.fax}<br />
{$Contacts.email}<br />
{* you can print arrays of arrays as well *}
{$Contacts.phone.home}<br />
{$Contacts.phone.cell}<br />