Hi group,
just wondering:
I have a database, containing the following fields:
name
address
zip
email
and a template for my page, containing the following tags:
[[name]] [[address]] [[zip]] [[email]]
Would there be a quick way to replace those tags with the data read from the
database without doing this:
$line=mysql_get _row($res) ; // provided we already have connection and data
selected
$html_to_show=p reg_replace("/\[\[name]]/",$line[0],$html_to_show) ;
$html_to_show=p reg_replace("/\[\[address]]/",$line[1],$html_to_show) ;
$html_to_show=p reg_replace("/\[\[zip]]/",$line[2],$html_to_show) ;
$html_to_show=p reg_replace("/\[\[email]]/",$line[3],$html_to_show) ;
(never mind the preg here or any typo's. this is a quick question)
Reason for me to ask, though code above works:
I need to create something dynamic. I would like to scan and replace every
instance in my template, looking like a tag ( [[some_tag_name]] ) by
the value of it's corresponding fieldname from my table.
I am really wondering how, but there's got to be an easier way to do this.
Currently I have 61 fields in one table and that kinda works towards RSI if
I have to code it all like this.
Anyone with a good suggestion, apart from reading the manual? (I am already
doing that)
Thank you very much in advance,
Michel
PS: sorry for double posting this.
just wondering:
I have a database, containing the following fields:
name
address
zip
and a template for my page, containing the following tags:
[[name]] [[address]] [[zip]] [[email]]
Would there be a quick way to replace those tags with the data read from the
database without doing this:
$line=mysql_get _row($res) ; // provided we already have connection and data
selected
$html_to_show=p reg_replace("/\[\[name]]/",$line[0],$html_to_show) ;
$html_to_show=p reg_replace("/\[\[address]]/",$line[1],$html_to_show) ;
$html_to_show=p reg_replace("/\[\[zip]]/",$line[2],$html_to_show) ;
$html_to_show=p reg_replace("/\[\[email]]/",$line[3],$html_to_show) ;
(never mind the preg here or any typo's. this is a quick question)
Reason for me to ask, though code above works:
I need to create something dynamic. I would like to scan and replace every
instance in my template, looking like a tag ( [[some_tag_name]] ) by
the value of it's corresponding fieldname from my table.
I am really wondering how, but there's got to be an easier way to do this.
Currently I have 61 fields in one table and that kinda works towards RSI if
I have to code it all like this.
Anyone with a good suggestion, apart from reading the manual? (I am already
doing that)
Thank you very much in advance,
Michel
PS: sorry for double posting this.
Comment