Page 1 of 1

having trouble passing/echoing variables in php tpl file

Posted: Wed Oct 05, 2005 10:34 pm
by deras
i created a page which is supposed to display a number of database records, 3 at a time from my mysql database. to do this i have more.php (code) and more.tpl.php (html template) file. on the page going into more.php i am sending (using httpd get) a $pastcount variable with a value of "3".

relevant more.php code

Code: Select all

<?php
$tpl = new tpl("more");
$dat = Array();
$fnd = 0;
$pastcount = $_GET['pastcount'];
$rcount=$pastcount+3;
$res = mysql_query("select * from ratings order by tm desc limit $rcount,3");
relevant more.tpl.php code

Code: Select all

<form method="get" action="/more.php">
							<div align="center">
<input name="pastcount" type="hidden" value="<?$pastcount;?>">
						<input value="Next 3 Reviews" type="submit"></div>

the problem is that the template file does not echo the variable, so it does not work. any idea why the variable is not echoing and how i can get it to?

Posted: Wed Oct 05, 2005 10:39 pm
by John Cartwright
change

Code: Select all

<input name="pastcount" type="hidden" value="<?$pastcount;?>">
to

Code: Select all

<input name="pastcount" type="hidden" value="<? echo $pastcount;?>">
or

Code: Select all

<input name="pastcount" type="hidden" value="<?=$pastcount;?>">

Posted: Wed Oct 05, 2005 11:19 pm
by harrisonad
Jcart wrote:

Code: Select all

<input name="pastcount" type="hidden" value="<?=$pastcount;?>">
semilon is optional if php end tag exists

Code: Select all

value="<?=$pastcount?>"