php - Mysql result loop for template engine -


what trying loop results use of simple template engine. problem script executes same result many times.. right there 3 test works in database(test_1,test_2,test_3), result looks now:

test_3 test localhost

test_3 test localhost

test_3 test localhost

$result = $pdatabase->query($query) or die('query failed: ' . mysql_error());     while ($row = mysql_fetch_array($result)) {         //loop template (row)         $works_row = new template("works_row.tpl");              //changing $row[] {}             $rows[]=$row;             $works_row->set("category",$row['category']);             $works_row->set("name",$row['name']);             $works_row->set("link",$row['link']);     }     foreach ($rows $row) {     $works_templates[] = $works_row;     }     $works_contents = template::merge($works_templates);     mysql_free_result($result);     //content part calls works     $works_list  = new template("works_block.tpl");      $works_list->set("works_rows", $works_contents); 

i don't understand why doesn't work right

try ,it works

    $result = $pdatabase->query($query) or die('query failed: ' . mysql_error());     while ($row = mysql_fetch_array($result)) {         //loop template (row)         $works_row = new template("works_row.tpl");              //changing $row[] {}             $rows[]=$row;             $works_row->set("category",$row['category']);             $works_row->set("name",$row['name']);             $works_row->set("link",$row['link']);             $works_templates[] = $works_row;     }      $works_contents = template::merge($works_templates);     mysql_free_result($result);     //content part calls works     $works_list  = new template("works_block.tpl");      $works_list->set("works_rows", $works_contents); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -