having trouble passing/echoing variables in php tpl file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deras
Forum Newbie
Posts: 24
Joined: Sun Nov 02, 2003 10:26 am

having trouble passing/echoing variables in php tpl file

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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;?>">
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post 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?>"
Post Reply