Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- this is "inc/Database.php" -->
- <?php
- class database{
- public $server = "";
- public $user = "";
- protected $dbName;
- protected $password = "";
- public $error = array();
- protected $conn;
- public function __construct($server, $user, $password, $databaseName){
- // check if the server is set
- if($server == "")
- {
- $this->error[] = "server is empty";
- }
- // check if the password is set
- if($user == "")
- {
- $this->error[] = "user is empty";
- }
- // check if the server is set
- if($password == "")
- {
- $this->error[] = "password is empty";
- }
- // check if the password is set
- if($databaseName == "")
- {
- $this->error[] = "databaseName is empty";
- }
- $this->server = $server;
- $this->user = $user;
- $this->password = $password;
- $this->dbName = $databaseName;
- }
- function conn(){
- $conn = mysqli_connect($this->server, $this->user, $this->password, $this->dbName);// database connection
- return $conn;
- }
- function select($colum = false, $table = false){
- $this->conn = conn();
- if(!$conn)
- {
- die("woops");
- }
- //maak verbinding
- //SELECT name FROM landen
- $sql = "SELECT ".$colum." FROM ". $table; //de SQL string
- $query = mysqli_query($conn, $sql); // Query uitvoeren
- mysqli_close($conn); // verinding sluiten
- return $query; // geef relultaat terug
- }
- function selectWhere($colum, $table, $where){
- $this->conn = conn();
- // SELECT name FROM landen WHERE landID=3
- $sql = "SELECT '".$colum."' FROM '".$table."' WHERE ".$where;
- $query = mysqli_query($conn, $sql);
- mysqli_close($conn);
- return $query;
- }
- function insert($table, $colums,$values){
- $this->conn = conn();
- // INSERT INTO landen (name) VALUES (Duitsland)
- $sql = "INSERT INTO ".$table." (".$colums.") VALUES (".$values.")";
- // INTERT INTO producten (type,bouwjaar,prijs,image)
- // VALUES ("A4")
- mysqli_query($conn, $sql);
- $lastID = mysqli_insert_id($conn); // EXTRA VOOR DEZE OPDRACHT
- mysqli_close($conn);
- return $lastID;
- }
- // make function array weg te schrijven
- /* function insertArray($array, $table)
- {
- $this->conn = conn();
- foreach($array)
- // INSERT INTO landen (name) VALUES (Duitsland)
- $sql = "INSERT INTO ".$table." (".$colums.") VALUES (".$values.")";
- // INTERT INTO producten (type,bouwjaar,prijs,image)
- // VALUES ("A4")
- mysqli_query($conn, $sql);
- $lastID = mysqli_insert_id($conn); // EXTRA VOOR DEZE OPDRACHT
- mysqli_close($conn);
- return $lastID;
- }*/
- }
- ?>
- <!-- this is my index.php -->
- <?php
- require('inc/Database.php');
- $database = new database("localhost","root","", "rocthat");
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- <title>Home</title>
- <link href="./css/reset.css" type="text/css" rel="stylesheet" />
- <link href="./css/myStylesheet.css" type="text/css" rel="stylesheet" />
- <meta name="keywords" content="Roc that, rocthat, roc that, muziek" />
- <meta name="description" content="This is the main page of Roc That" />
- <meta name="author" content="Kevin Neven" />
- <meta name="copyright" content="1-10-2015" />
- </head>
- <body>
- <?php
- $data = $database->selectWhere("html", "html", "html.name = 'header'");
- while($row = mysqli_fetch_assoc($data))
- {
- $header[] = $row;
- }
- foreach($header as $header)
- {
- echo $header;
- }
- /*echo "<div class='header'>
- <img src= './img/header/Header.png' align='center'>
- <ul class='menu'>
- <li><a href='index.html'>Homepage</a></li>
- <li><a href='contact.html'>Contact</a></li>
- <li><a href='tour.html'>The tour</a></li>
- <li><a href='discography.html'>discography</a></li>
- <li><a href='gallery.html'>Gallery</a></li>
- <li><a href='fanpage.html'>Fanpage</a></li>
- <li><a href='theband.html'>The band</a></li>
- </ul>
- </div>";*/?>
- <div class="mainDiv">
- <!-- images : height: 60px; -->
- <!-- menu : width: 180px; -->
- <!-- place 6 menu-items (links) to 6 different documents -->
- <!--
- the documents (pages) :
- homepage : index.html
- contactpage : contact.html
- about page : about.html
- discography : discography.html
- tour page : tour.html
- gallery : gallery.html
- -->
- <!-- place the links into a list -->
- <div class="content">
- <h1>Homepage</h1>
- <p style="margin-top: 30px;">
- Hi there! This is the website of Roc That.<br />
- In our website you can find our webshop and pictures and all sorts of things.
- </p>
- </div>
- <!-- content and width will be defined automatically -->
- <!-- footer : height: 90px; -->
- <div class="footer">
- <table>
- <tr>
- <td>
- test
- </td>
- <td>
- test
- </td>
- <td>
- test
- </td>
- </tr>
- </table>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement