Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    assign This with Smarty

    Hello

    This Code gets the Data from The Mysql and Prints the Result in Columns , How to assign that into Template with Smarty .. i saw Tutorial Here but the Code was Messed up.
    http://smarty.incutio.com/?page=SmartyColumnsTutorial

    My code.
    PHP Code:
    // Connect host
    $con=@mysql_connect($db_host,$db_user,$db_pass) or die ('No Connect');
    // Select db
    $sel=@mysql_select_db($db_name,$con) or die ('No Select');
    //////////////////////////////////////////////////////////////////////////////////////////
    $count=0;
    $cols=3//coumnts #
    //read data
    $sql=mysql_query("select * from test");

    echo
    "<table border='1' width='50'>\n";

    while(
    $row=mysql_fetch_array($sql)){

    if(
    $count == 0) echo "<tr>\n";

    $count++;

    echo 
    "<td>".$row['name']."</td>\n";

    if(
    $count==$cols){

    echo 
    "</tr>\n";

    $count=0;
    }
    }
    echo 
    "</table>"

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    Here is the quick start guide
    http://www.smarty.net/quick_start.php
    It's just a matter of assigning values using
    PHP Code:
    $smarty->assign('templat_var_name'$variable); 
    You can assign a whole array if you wish. Smarty templates allow most if not all php functionality
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

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