How to insert a variable into a PHP template.
| From: | Steve Jackson | Date: | Mon, 07 Jul 2003 12:34:46 +0000 |
| Subject: | How to insert a variable into a PHP template. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-154174@lists.php.net to get a copy of this message | ||
Hi,
I want to write a PHP template with a variable number of the last
recordset in a MySQL DB being the number referenced in the file. This is
so my file can be saved as a PHP page looking at the right content in a
database for a content management system. I am stuck on the way to do
it. The code below is the part I want to change:
So I need to do two things:
1) Select the last record in a database table.
2) get PHP to write all the code below on the fly.
////////////////////////
db_connect();
// This is the query number which needs to be changed and written every
time as the last record in the DB
$query = "select * from crm_content where PageID='1'";
$result = mysql_query($query) or die("Error: Query failure
with<BR>$query<BR>".mysql_error());
while ($array = mysql_fetch_array($result))
{
$PageTitle = "{$array["Title"]}";
$BodyText = "{$array["BodyText"]}";
$Picture1 = "{$array["PictureOne"]}";
$Picture2 = "{$array["PictureTwo"]}";
$CatID = "{$array["CatID"]}";
}
// then write the function to call the page here
//////////////////////
Any ideas thoughts or help much appreciated.
Steve Jackson
Web Development and Marketing Manager
Viola Systems Ltd.
http://www.violasystems.com
stephen.jackson@violasystems.com
Mobile +358 50 343 5159