NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Help please : php template system

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 09-18-2007, 11:57 AM THREAD STARTER               #1 (permalink)
Account Suspended
 
shahzad11's Avatar
Join Date: Nov 2006
Location: Lahore
Posts: 297
shahzad11 is on a distinguished road
 



Help please : php template system


I am developing a template based site written in php+mysql i have arranged all the things but now i wanna display my data from sql and display via my template but it gives errors to me

please suggest me the right method


here are my

files attacher with



my index file code

Quote:
<?php require_once('Connections/songs.php'); ?>
<?
$username="******";
$password="******";
$database="******";

mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM songs ";
$result=mysql_query($query);
$rowresult = mysql_fetch_assoc($result);


$num=mysql_numrows($result);

mysql_close();


?>
<?php

require "template.class.php";
require "config.php";
$tpl->file("design.html");

$tpl->replacement(array(

// head tags defined//
"pagetitle" => "$pagetitle",
"keywords" => "$keywords",
"description" => "$description",
//-----------------------------//

// nav bar tabs construction//
"tab6" => '<div id="nav-tabs"><a href="http://www.urparadise.com">SMS Site</a> </div>',
"tab5" => '<div id="nav-tabs"><a href="video-songs.php">Video songs </a> </div>',
"tab4" => '<div id="nav-tabs"><a href="eng-songs.php">English songs </a> </div>',
"tab3" => '<div id="nav-tabs"><a href="indian-songs.php">Indian songs </a> </div>',
"tab2" => '<div id="nav-tabs"><a href="paki-songs.php">Paki songs </a> </div>',
"tab1" => '<div id="current-tab"><a href="index.php">Home</a> </div>',
//----------------------------------//

//header ad place//
"header-ad" => "$headerad",
//-------------------//


// submit form is here
"contents" => " ",

//------------------------------------------------------------------------------------------//
"nav" => "$nav",
"header" => "$header",
"slogan" => "$slogan",
"footer" => "$footer",


));

$tpl->display();

?>
<table width="100%" border="1px" align="center" cellpadding="3" cellspacing="0" bordercolor="#FFCC00">
<tr>

<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<? $i=0; while ($i < $num) {?>

<tr>
<td><?php echo $rowresult['title']; ?></td>
<td><a href="<?php echo $rowresult['url']; ?>"><?php echo $rowresult['url']; ?></a></td>
<td><?php echo $rowresult['type']; ?></td>
<td><?php echo $rowresult['album']; ?></td>
<td><?php echo $rowresult['singer']; ?></td>
<td><?php echo $rowresult['movie']; ?></td>
<td><?php echo $rowresult['id']; ?></td>
</tr>
<? $i++; }?></table>

here is my config.php code

Quote:
<?

//Meta tags can be edited here//--
$pagetitle="Get free ringtones free wallpapers free gsm codes";
????: NamePros.com http://www.namepros.com/programming/375497-help-please-php-template-system.html
$keywords="ringtones, wallpapers, songs";
$description="ringtones, wallpapers, songs";


// main navigation bar is built here//--

$nav='<a href="index.php">Home</a> | <a href="products.php">Products</a> | <a href="links.php">Links</a> | <a href="about-us.php">About Us</a> | <a href="contact-us.php">Contact Us</a>';
//----------------------------------------------------------------------------------------//


//change your header name//--

$header="Ur Paradise";
$headerad='<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-0882793319829430";
????: NamePros.com http://www.namepros.com/showthread.php?t=375497
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-09-11: urparadise.com
google_ad_channel = "5439651693";
google_color_border = "0066cc";
google_color_bg = "FFFFFF";
google_color_link = "ff6600";
google_color_text = "0066cc";
google_color_url = "008000";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


</div>';


//----------------------------------------------------------------------------------------//

$slogan = "The Technology Blog";
$footer = "Copyright@gsmskills.com" ;
//----------------------------------------------------------------------------------------//

$contents= "";




?>
here is my template class code

Quote:
<?php

//-----------------------------------------------------------------
// Template System Class
// Made by Adrian Crepaz at Dreamit.co.uk

// Feel free to use this code in your own scripts.
// For information on how to use the Class, see here, http://www.dreamit.co.uk/php-template-system-class/
// Please do not re-distribute this code seperatly, or as your own
//-----------------------------------------------------------------

class Tpl
{
var $file;

function file($user_file)
{
if(file_exists($user_file))
{
$this->file = file_get_contents("" . $user_file . "");
}
else
{
die ("Sorry, the following file, " . $user_file . " could not be found.");
}
}

function replacement($tags = array())
{
if(count($tags) == 0)
{
die ("No tags defined for Template Tag replacement.");
}
else
{
foreach($tags AS $tag => $replace)
{
$this->file = str_replace("{" . $tag . "}", $replace, $this->file);
}
}
}

function display()
{
echo $this->file;
}
}

$tpl = new tpl;

?>
here is my template design

Quote:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>{pagetitle}</title>
<meta name="keywords" content="{keywords}" />
<meta name="description" content="{description}" />

<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="777" height="535" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="85" colspan="3" valign="top" class="header">{header}</td>
<td width="50">&nbsp;</td>
<td width="470" valign="middle"><div align="right">{header-ad}</div></td>
<td width="7">&nbsp;</td>
</tr>
<tr>
<td width="135" height="8"></td>
<td width="15"></td>
<td width="100"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="23" colspan="6" align="center">
{tab6} {tab5} {tab4} {tab3} {tab2} {tab1} </td>
</tr>
<tr>
<td height="13" colspan="6" valign="top" class="tab-bottom-bar"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="14"></td>
<td></td>
<td></td>
<td valign="top"></td>
<td valign="top"></td>
<td></td>
</tr>
<tr>
<td height="392" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td valign="top">&nbsp;</td>
<td colspan="4" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="627" height="392" valign="top"><p>{contents}</p>
<p>&nbsp;</p></td>
</tr>
</table> </td>
</tr>
</table>
<table width="777" align="center">
<tr>
<td class="copy-rights">{footer}</td>
</tr></table>
</body>
</html>
Last edited by SecondVersion; 09-19-2007 at 01:53 PM.
shahzad11 is offline  
Closed Thread


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


 
All times are GMT -7. The time now is 02:25 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger