MMD2 Multimedia Design PHP

HTML Kickstart og PHP

HTML Kickstart wireframe
HTML Kickstart wireframe

HTML Kickstart ( giver et framework til hurtig udvikling af html. Siderne kan konverteres til .php sådan:

  • Gem din fil som minfil.php
  • Herefter kan kode genbruges ved includes.

Det kan være en god ide at lave en skitse over din side, således at du får en ide om, hvad du vil udvikle.

Husk at en række = 12 kolonner.

1semE14 MMD2 PHP

PHP: Cookie, Array, Loop

A cookie is saved locally. Therefore different browsers will display whatever the user has saved. At least as long as the cookie is alive.
A cookie is saved locally. Therefore different browsers will display whatever the user has saved. At least as long as the cookie is “alive”.

The complete code to this article is available here.

We use cookies in order to save information about or from the user input. If you compare my Firefox and Chrome browsers they will format the Microlite roleplaying web page according to random values, dates and saved input. Computergames use random values in stead of dice. First the character is saved in an associative array.

// Define the character array.
// “key” => value
$character = array(
“strength” => rand(3,18),
“dexterity” => rand(3,18),
“mind” => rand(3,18),
“charisma” => rand(3,18),
“class” => $class[rand(0, $classes)],
“race” => $race[rand(0, $races)],
“address” => “Shire”,
“hitpoints” => rand(3,18),
“level” => 1,

Above you see the method in action. rand(3,18) is an imitation of the role playing “3d6” (throw 3 sixsided dices). The random generator will give a value between 3 and 18. If you read the rules of Microlite 84 it’s easy to add more character properties.

The cookie

In this case we’ll save the character data in a cookie in the client browser. However a cookie can only store a string. PHP can convert an array to a string:

$toCookie = serialize($character);

Now we can save the data in a cookie via setcookie:

setcookie(“character”, $toCookie, time()+ (60 * 60 * 60 * 24));

After the cookie has been set PHP can use the data. That is next time the page is read. PHP can check whether the cookie exists by isset($var):

if(isset( $_COOKIE[“character”] ) ) {

$charUnSer = unserialize($_COOKIE[“character”]);¬†


This will convert the cookie string to an array.

The Loop

In order to echo or print the values of the array to a table:

foreach ($charUnSer as $key => $value)
print ”
<td> $key </td> <td> $value </td>

And this loop will then create the character table in the wbbage.


Xampp and Gmail SMTP

Here is a PHP mail library that works with Gmail SMTP and Xampp:

Download all code as a zip and unzip somewhre in htdocs.

In the unzipped folder go to


find the file gmail.phps and copy the file
paste it and rename to gmail.php

Edit the file and add your user details. For the sake of the test let the recipient be yourself.
If you fire off the file and get a mail then it works.

And it worked for me in Xampp.

MMD2 Multimedia Design PHP

Principles of PHP

Here is a very short introduction to the principles of PHP. ¬†PHP is an acronym for “hypertext preprocessor”. PHP is a serverside language. We use PHP in order to prepare webpages, react to user input – and (on the third semester) to interact with databases.

Many Open Source CMSs use a combination of Apache, PHP and MySQL as an “engine”.

How to write PHP code

A php file is made in a manner similar to a HTML file. You create a file and give it the surname .php. So a file name sample could be:

  • myFile.php

The file can contain other forms of code and tags such as JavaScript, CSS or HTML. In the file the php code is nested between a <? and ends with a ?>.

Variables, Strings and numbers

$a = 10; // a number
$b = “Hello World”; // a string
$c = “Ho, ho, hooo!”; // yes it’s another string
$d = “Santa Claus, says: “; // xmas is near
$combinedStrings = $d . $c; // Santa Claus, says: Ho, ho, hooo!
$e = NULL; // no value set
$f = true; // or false

A variable is defined via the $ character. In the sample code above you can see several variables.

A string starts and ends with a quotation mark as ” or ‘. If you need quotation marks inside a string they should be nested like this:

<? $foo = “<img src=’image.png’ ¬†alt=’an image’ />”; ?>

You can create HTML code via PHP – and you can show an image on a web page like this:

<? echo $foo; ?>


<? print(“$foo”); ?>


Since a variable can be a number, you can use PHP for calculations, such as:

$x = 1;
$y = 19;
echo $x + $y; // should return 20

See this page for more information about PHP and calculations.






Bootstrap CSS MMD2 PHP Uncategorized WordPress

WordPress theme with Bootstrap

An excellent tutorial by Zac Gordon: “How to Build a Responsive WordPress Theme with Bootstrap”. ¬†You’ll learn to hack a WP theme from scratch with Bootstrap and jQuery enabled.

$wpdb Database Modelling PHP WordPress

WordPress Рopsætning på EAL


  • Bruger:
  • Password: *********
  • Database: xxxx_mmd_eal_dk

Filen wp-config.php kommer til at se sådan ud:

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘xxxx_mmd_eal_dk’);

/** MySQL database username */
define(‘DB_USER’, ‘’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘*******’); // password hidden here ūüėČ

/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);


Debugging med grep

-n viser linjenummeret. Ved at s√łge p√• fx grep ‘div’ og ‘/div’ i en fil bliver det tydeligt, hvor start og sluttag findes i filen:

per@debian-petj:~/Skrivebord/webkanban$ grep '</div' KbnBoard.php -n
16:	<div id='icon-edit-pages' class='icon32'></div><br />
107:			</div>";
111:		echo "</div>";
112:		echo "</div>";

We use cookies - is it ok with you+ more information will set a few cookies from Doubleclick, Google and the Social Media plugins they ay set some cookies.