- Impact
- 4
hi,
i made a code (to do with a template system) but im having trouble.
i get the infomation from the database and try to put the data into two functions which have in them a switch.
the file is included from a diffrent file when it needs to know things such as the sites name etc...
but i can get it working
heres the code, whats wrong?
i made a code (to do with a template system) but im having trouble.
i get the infomation from the database and try to put the data into two functions which have in them a switch.
the file is included from a diffrent file when it needs to know things such as the sites name etc...
but i can get it working
heres the code, whats wrong?
PHP:
<?php
mysql_connect("localhost", "root", "*password*") or die(mysql_error());
mysql_select_db("topsite") or die(mysql_eror());
$result = mysql_query("SELECT * FROM tags");
$mysql_tag = mysql_fetch_array($result);
mysql_free_result($result);
//Site() template tags
function site($tag){
switch ($tag) {
case "name":
echo $mysql_tag["site_name"];
break;
case "url":
echo $mysql_tag["site_url"];
break;
case "slogan":
echo $mysql_tag["site_slogan"];
break;
case "subject":
echo $mysql_tag["site_subject"];
break;
case "email":
echo $mysql_tag["site_email"];
break;
}
}
//Meta() template tags
function meta($tag){
switch ($tag) {
case "keywords":
echo $mysql_tag["meta_keywords"];
break;
case "description":
echo $mysql_tag["short_description"];
break;
case "title":
echo $mysql_tag["short_short_description"];
break;
}
}
?>





