Php template engine

Ai o întrebare legată de PHP? Incercăm să îi găsim soluţie. Sau poate doar vrei să publici un cod interesant.

Moderatori: Zamolxe, Moderatori

zoomless
New Member
Mesaje: 1
Membru din: Dum Noi 01, 2015 6:57 pm

Php template engine

Mesajde zoomless » Sâm Noi 14, 2015 10:57 pm

Salut, sper sa ma puteti ajuta cu o mica eroare.

Intr-o functie php am urmotorul cod:

function view(){
global $tpl, $username, $id;
$query = mysql_query("select id, username from table");
while ($data = mysql_fetch_assoc($query)) {

$id .= $data['id'].'</br>';
$username .= $data['username'].'</br>';

$tpl->assign_var('USERNAME', $username);
$tpl->assign_var('ID', $id);

}}

In template.html am:
{ID}{USERNAME}

In browser imi afiseaza astfel:

id: 1
id: 2
username: test
username: test1

Eu as vrea sa-mi afiseze in felul urmtor:

id: 1
username: test
id: 2
username: test1
Ultima oară modificat Dum Noi 15, 2015 11:28 am de către zoomless, modificat 1 dată în total.



nevvermind
Senior Member
Mesaje: 1264
Membru din: Mar Iun 22, 2010 3:17 pm

Re: Php template engine

Mesajde nevvermind » Dum Noi 15, 2015 2:08 am

a) ce tpl engine e ala?
b) deci folosesti "assign_var" sau "echo" pana la urma, ca n-am inteles?
c) cum printeaza cel engine un template? nu prea imi dau seama cum poate apare asa cum ai scris.
Facusi un canal de php pe freenode - ##php-ro : https://webchat.freenode.net/


Înapoi la “Cod PHP”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 59 vizitatori