Current location: Hot Scripts Forums » Programming Languages » PHP » Variables from templates in the database


Variables from templates in the database

Reply
  #1 (permalink)  
Old 06-28-04, 03:49 PM
dannyallen dannyallen is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Variables from templates in the database

I have a system for fetching templates from a database and showing them on my website, but in my function, I have to define every variable that is in the template. Here is my function and me showing the template below it.
Code:
function show_template($name) {

$board[boardname] = 'Testing';

$query = "SELECT * FROM templates WHERE name = '$name'";
	
$result = @mysql_query($query) or die("Query failed : " . mysql_error());
	
	while ($template = @mysql_fetch_array($result)){
		
		eval("\$templateshow = \"$template[template]\";");

		echo $templateshow; }}

show_template('global_header');
You see, $board[boardname] is in my template in the MySQL database. I want to be able to just run the function without having to define the board[boardname] variable inside the function. This would allow me to use my templates more efficiently so I don't have to define everything inside my template function.

Is there anyway to do this while still showing the correct variable even though it is defined outside the function?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 01:41 AM
Displaying variables from the database mishmia PHP 2 05-14-04 07:42 PM
Extract variables from a database andreasberglind ASP.NET 1 08-28-03 09:17 AM
Share database over the Internet nitinkedia New Members & Introductions 1 07-10-03 02:50 PM


All times are GMT -5. The time now is 05:07 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.