SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Arrow SMARTY, how do you pull data from MySQL and store into array...

    Hello

    How do you pull MULTIPLE COLUMNS from Mysql then store the values into array using PHP and later display it onto SMARTY?

    Can you show example codes for this please.

    Anyone out there with humble heart please.
    I"m scratching my head for this in many days.

    Thanks in advance.

  2. #2
    Non-Member thewebhostingdir's Avatar
    Join Date
    Oct 2005
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I exactly do not understand the requirement. When you write a SELECT query as per your needs and then do mysql_fetch_array(), it will return the array of columns. Please elaborate the needs if different.

  3. #3
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    @thewebhostingdir

    can you help me. please...

  4. #4
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    *bump*
    any help please.

  5. #5
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    It's in the documentation, in fact, it's on this very page.

    http://www.smarty.net/manual/en/api.assign.php
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    I'm new to smarty so take this with a grain of salt:

    Assign headings and row data:

    PHP Code:
    ...
    $smarty->assign('myHeadings',$headings);
    $smarty->assign('myData',$data); 
    Template:

    PHP Code:
    <table>

    {foreach 
    key=key item=value from=$myHeadings name=outerHead}
    {if 
    $smarty.foreach.outerHead.first}<thead><tr>{/if}
        <
    td>{$value}</td>
    {if 
    $smarty.foreach.outerHead.last}</tr></thead>{/if}
    {/foreach}

    {foreach 
    key=key item=value from=$myData name=outer}
    {if 
    $smarty.foreach.outer.first}<tbody>{/if}
    <
    tr>
        {foreach 
    key=key2 item=value2 from=$value}
            <
    td>{$value2}</td>
        {/foreach}
    </
    tr>
    {if 
    $smarty.foreach.outer.last}</tbody>{/if}
    {/foreach}

    </
    table


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •