Hi Debreceni, 

I need to use a template parser, and XTemplate looks like it will do what I
need, but I'm not sure how. I can use mysql_fetch_array to produce an array
of field_name:value.  If I use {field} names in the html template, can I use
XTemplate to take the array and parse?

This is what I have so far - please look at the ASSIGN step

<?
$id=1; //parameter for sql select, determines which row is selected
$user="user";
$pass="pass";
$database="database";
$sql="select * from table where id = $id"; //returns ONE row (id is a PK)

$link_id = mysql_connect($database); //identify connection handle

if (!$link_id)  { die(sql_error()); } //test for connection handle
              
else { mysql_select_db($database, $link_id)  }  //select database

$result = mysql_query($sql, $user, $pass); //return row to php

$page_array = mysql_fetch_array($result);
//this creates array of field name:data,
//eg $page_array[firstfield] has value of 'firstfield' for $id

require "xtpl.p"; //include XTemplate engine
require "html.xtpl"; //html layout file with field names e.g. {firstfield}

$xtpl->assign($page_array); //HELP! How is this step done?
                            //I already have an array that assigns field
                            //names to data elements, how can I skip this?
                            //I don't want to assign each element since then
                            //I would need one .p page for each .xtpl page

$xtpl->parse("main");//replace {field} with matching result row element
$xtpl->out("main");` //send final html page to browser
?>

Does this make sense?

Thanks in advance for any help!

Regards,
Jaxon


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to