I have a template system that parses all tags like {HEAD} in the .tpl file.
I want to read all data from the db and add each one to a different variable.
I have tried stuff like:
[code=php]
$no = “1”;
while($row = mysql_fetch_array($result)){
$t.$no = “$row[‘text’]”;
$no++;
}
$titles = array(
‘T1’ => $t1,
‘T2’ => $t2,
‘T3’ => $t3,
‘T4’ => $t4,
‘T5’ => $t5,
‘T6’ => $t6,
‘T7’ => $t7,
‘T8’ => $t8,
‘T9’ => $t9,
‘T10’ => $t10,
‘T11’ => $t11,
‘T12’ => $t12,
‘T13’ => $t13,
‘T14’ => $t14,
‘T15’ => $t15
);
echo parse(‘index’,$titles);
?>
But didnt work, I was wondering if I could do
[code=php]
$no = “1”;
while($row = mysql_fetch_array($result)){
$t1 = $row[“text[1]”];
……
$t15 = $row[“text[’15’]”];
}
$titles = array(
‘T1’ => $t1,
‘T2’ => $t2,
‘T3’ => $t3,
‘T4’ => $t4,
‘T5’ => $t5,
‘T6’ => $t6,
‘T7’ => $t7,
‘T8’ => $t8,
‘T9’ => $t9,
‘T10’ => $t10,
‘T11’ => $t11,
‘T12’ => $t12,
‘T13’ => $t13,
‘T14’ => $t14,
‘T15’ => $t15
);
echo parse(‘index’,$titles);
?>
and maybe be able to use that without having to add all of them til 15. Could I use an array there like
[code=php]
$t[$no] $row[“text[$no]”];
Are there any other methods that are faster or use less bandwidth?
Aoeguy