PHP Şablon Kullanarak

0 Cevap

benim site için bir şablon dosyası oluşturmak ... sanki:

<!-- template.php -->
<?php function showheader() { ?>
<head><body>
<!-- some of style files and menus -->
<div class="content">
<?php } ?>

<?php function showfooter() { ?>
</div></body></html>
<?php } ?>

ben böyle bir şablon olarak bu dosyayı kullanabilirsiniz:

<?php include_once("template.php"); showheader(); ?>
content text or photo or ... etc.
<?php showfooter(); ?>

that's all... but if i try to use a connection on template file, it screw up! i used an external file like:

<?php
//
// include_once connection file
// query strings goes here
//

do {
echo $row_table['id']; //example
} while ($row_table = mysql_fetch_assoc($table));

?>

ve i include_once ("filename.php") olarak bu dosyayı kullanmak; şablon dosyası üzerinde ... Bu noktada bu bağlantı değişkenin ne gibi, bu bağlantı dizeleri ulaşamaz vs ... bu bağlantı dizesi budur ... hataları verir ...

Bu arada, ben gibi başka bir harici bağlantı kullanmasına:

<?php
global $hostname_conn,$database_conn,$username_conn,$password_conn,$conn;
$hostname_conn = "localhost";
$database_conn = "test";
$username_conn = "****";
$password_conn = "****";
$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR); 
mysql_query("SET NAMES 'utf8'");
?>

i'm gonna cry! what's the problem... and do you know another way to use template... thanks much...

PS: Ben küresel olarak conn.php üzerine değişkenleri değiştirmek (ve işe yaramadı) ve ben, include_onceyi dahil değiştirmek, ihtiyaç, require_oncenin i dosyalarını içerir ama bu nereye şey vermedi.

0 Cevap