Unfinished template system with PHP & MySQL

Elite Diviner
Joined
Mar 4, 2011
Messages
418
Reaction score
44
Hey, I am not back to stay just to look around.
Heres my unfinished template system, this is not for somebody looking to use it considering its not even closed to finished. I was just testing around with stuff and I got to bored with it so I am releasing it.
If you know how to finish it, congrats.
Here ya go
connect.php
PHP:
<?php
require_once('config.php');
$lol = mysql_connect($dbhost,$dbuser,$dbpassword);
mysql_select_db($db,$lol);
if(!$lol){
die('<img src="http://cdn.memegenerator.net/instances/400x/16391317.jpg" />');
}
else{
}
?>
lol @ meme :P
config.php (change settings)
PHP:
<?php
$dbuser = "root"; 
$dbhost = "localhost";
$dbpassword = "pass"; 
$db = "db"; 
?>
index.php
PHP:
<html>
<body>
<head>
<title>Test</title>
</title>
<?php
require_once('connect.php');
$lol = mysql_query("SELECT * FROM style");
$lol123 = mysql_fetch_assoc($lol);
$bg = $lol123['background-color'];
$font = $lol123['font-family'];
$color = $lol123['link-color'];
echo '<style type="text/css">
body{
background-color:#';
echo $bg;
echo ';';
echo 'font-family:';
echo $font;
echo ';}';
echo '';
echo 'a:link {color:#';
echo $color;
echo '}';
echo 'a:visited {color:#';
echo $color;
echo ';}';
echo '.ex
{
width:100%px;
height:100px;
background-color:#336699;
margin: -8;
padding: 0em;
}';
echo '.loll
{
width:100%px;
height:26px;
background-color:#1D536E;
margin: -8;
padding: 6px;
};';
echo '</style>';
echo '<div class="ex">';
echo '</div>';
echo '<div class="loll">';
$res = mysql_query("SELECT * FROM navigator");
while ($row = mysql_fetch_assoc($res)) {
    echo ' ';
    echo '<a href="';
    echo $row["link"];
    echo '">';
    echo $row["name"];
    echo '</a>';
}
echo '</div>';
?>
and run this SQL.
-- phpMyAdmin SQL Dump
-- version 3.4.5
-- phpMyAdmin
--
-- Host: localhost
-- Generation Time: Mar 19, 2012 at 06:55 AM
-- Server version: 5.5.16
-- PHP Version: 5.3.8

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `temp`
--

-- --------------------------------------------------------

--
-- Table structure for table `navigator`
--

CREATE TABLE IF NOT EXISTS `navigator` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text NOT NULL,
`link` text NOT NULL,
`fontcolor` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `navigator`
--

INSERT INTO `navigator` (`id`, `name`, `link`, `fontcolor`) VALUES
(1, 'Test', 'http://google.ca', '000000'),
(2, 'LOL', 'falfh', 'FFFFFF');

-- --------------------------------------------------------

--
-- Table structure for table `style`
--

CREATE TABLE IF NOT EXISTS `style` (
`background-color` text NOT NULL COMMENT 'The background color of your website (HEX)',
`font-family` text NOT NULL COMMENT 'Font family for everything on your website',
`font-color` text NOT NULL COMMENT 'Font color of your font',
`link-color` text NOT NULL COMMENT 'Color of hyperlinks on your website',
`box-colors` text NOT NULL COMMENT 'Color of your boxes'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `style`
--

INSERT INTO `style` (`background-color`, `font-family`, `font-color`, `link-color`, `box-colors`) VALUES
('C0C0C0', 'Tahoma', '330000', 'FFFFFF', '3399CC');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
pls give me your constructive critism and if this helped you, like it. :love:
 
:P:
Well of course it is bad? Its just a base if someone wanted to do something with it..
instead of spamming next time post what would be 'better'.
I could give 2 shits what anybody thinks about this, considering i barley started it.
Please also consider I am still learning. Hope someone learns from this.
Its also just an example of what you could do with a template system.
Take this also into consideration - I havent even finished what I posted here.
 
:P:
Well of course it is bad? Its just a base if someone wanted to do something with it..
instead of spamming next time post what would be 'better'.
I could give 2 shits what anybody thinks about this, considering i barley started it.
Please also consider I am still learning. Hope someone learns from this.
Its also just an example of what you could do with a template system.
Take this also into consideration - I havent even finished what I posted here.

Here's the issue:

This isn't a template system.
This is including HTML and PHP in the same file. Without even attempting to separate much of anything.

A templating system organizes the code via separating PHP and HTML into different files. There's more to it then that, but that's always a good starting point.
 
Here's the issue:

This isn't a template system.
This is including HTML and PHP in the same file. Without even attempting to separate much of anything.

A templating system organizes the code via separating PHP and HTML into different files. There's more to it then that, but that's always a good starting point.

There was intended to be an admin panel to edit content and the layout such as the profile editor in userCP. I never got around to it. Sorry for trying, il stop.
:closedeyes:
 
Here's the issue:

This isn't a template system.
This is including HTML and PHP in the same file. Without even attempting to separate much of anything.

A templating system organizes the code via separating PHP and HTML into different files. There's more to it then that, but that's always a good starting point.
not to mention missing doctype, <head> inside <body>, missing closing tags, inline styles, messed up CSS(such as margin: -8 OR width:100%px), require_once() etc AFTER html AND LOADS AND LOADS of other messed up stuff..
 
@Putako
Don't give up. While this specific project may not be something you want to continue doing - keep at it (in general, not the project), it's all a learning experience.

not to mention missing doctype, <head> inside <body>, missing closing tags, inline styles, messed up CSS(such as margin: -8 OR width:100%px), require_once() etc AFTER html AND LOADS AND LOADS of other messed up stuff..
Well there were obviously tons of issues, but I was trying to encompass the broader issue of misunderstanding what a template system is.
 
I am aware how sloppy the code is, this was BARLEY started. It was just for people whom may use it or work off of it. Say somebody knew what to do, it would save the some time?
 
Back