php template loop function

Discussion in 'PHP' started by mbaldwin, Jan 19, 2010.

  1. #1
    Hi,
    Looking for a template loop function for php. I don't want a complete template engine, just a function to do loops. The loop data will be from a MySQL table, and put in to an html table.

    So, if anyone has a function I could have, or a tutorial on writing my own, or other resources you could point me to, I would appreciate it.

    Thanks,
    Michael
     
    mbaldwin, Jan 19, 2010 IP
  2. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
  3. mbaldwin

    mbaldwin Active Member

    Messages:
    215
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    95
    #3
    Thanks, but i don't really want a complete template engine, just a function for the loop part.
     
    mbaldwin, Jan 20, 2010 IP
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    As in you just want the php for the mysql looping and output? can you provide the code you have so far for the mysql just so that we know where you are up to
     
    JAY6390, Jan 20, 2010 IP
  5. mbaldwin

    mbaldwin Active Member

    Messages:
    215
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    95
    #5
    I already have the loopping for the mysql with php, I was trying to figure out how to get the looped data into an html page without putting in a lot of php code. I did figure out some code to do this.

    Thanks,
    Michael
     
    mbaldwin, Jan 20, 2010 IP
  6. the_cyber_world

    the_cyber_world Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The following works, but this could be inefficient, could save template in variable and str_replace markers:
    ob_start();
    foreach($aResults as $aResult) {
        require('templates/display_results.html');
    }
    $htmlResults = ob_get_clean();
    PHP:
     
    the_cyber_world, Dec 17, 2010 IP