[PHP] How to insert a variable into a PHP template.
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 withBR$queryBR.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 [EMAIL PROTECTED] Mobile +358 50 343 5159 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to insert a variable into a PHP template.
- Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, July 07, 2003 1:34 PM Subject: [PHP] How to insert a variable into a PHP template. 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. mysql_insert_id(); 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 withBR$queryBR.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. Can't help with this bit. Apart from putting it into a string and then writing it to a file. Regards Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to insert a variable into a PHP template.
mysql_insert_id(); How would I call that in my query? Because I tried that and I get resource ID=2 Also putting it into a string and writing it to a file, sounds good to me, that's what I was thinking but how do you do it? Can it just be written as: $string =all my code including ;''=}{[] etc; And then calling the string with fwrite? Or am I going to run into serious problems? Steve Jackson Web Development and Marketing Manager Viola Systems Ltd. http://www.violasystems.com [EMAIL PROTECTED] Mobile +358 50 343 5159 -Original Message- From: Andrew McCombe [mailto:[EMAIL PROTECTED] Sent: 7. heinäkuuta 2003 16:05 To: [EMAIL PROTECTED]; Steve Jackson Subject: Re: [PHP] How to insert a variable into a PHP template. - Original Message - From: Steve Jackson [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Monday, July 07, 2003 1:34 PM Subject: [PHP] How to insert a variable into a PHP template. 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. mysql_insert_id(); 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 withBR$queryBR.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. Can't help with this bit. Apart from putting it into a string and then writing it to a file. Regards Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php