MYSQL Query and TPL file

Discussion in 'PHP' started by tulip4heaven, Nov 1, 2008.

  1. #1
    Hi ,

    I have a PHP file "query.php" with mysql query in it which fetch records from a table , My site using Smarty templates "TPL" files , now i want to show records on site at left side which is left.tpl.

    How can i get output on my site

    Thanks
    Usman
     
    tulip4heaven, Nov 1, 2008 IP
  2. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #2
    Assign the mysql result to and display it in the tpl file. Read the SMARTY crash course for more in depth info: http://www.smarty.net/crashcourse.php
     
    Louis11, Nov 1, 2008 IP
  3. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    or alternatively you can put the query inside left.tpl and enclose it inside {PHP}{/PHP} tags
     
    shineDarkly, Nov 1, 2008 IP
  4. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #4
    That kind of defeats the benefit of separating your business logic from layout formatting code.

    The proper way to do it, is assign the value in the PHP and then display the tpl file (where you print the assigned value).
     
    Louis11, Nov 1, 2008 IP
  5. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yep, i dont really say, its a better way of doing it, if in any case he doesnt have any access to the source files ex: they are encrypted, then the OP could do it this way.
     
    shineDarkly, Nov 1, 2008 IP