12 April, 2013
PHP MySQLi - MySQL Improved connection
Since MySQL extension is deprecated and will be removed as of PHP 5.5 onwards, I'll be teaching you how to connect to a mysql database using the new method, MySQL Improved or MySQLi. I'll be writing 2 methods on how to connect and query on MySQLi.
1) Simple connection
//First I'll define variables
define("HOST","YOUR_MYSQL_HOST");
define("USER","YOUR_MYSQL_USERNAME");
define("PASS","YOUR_MYSQL_PASSWORD");
define("DBASE","YOUR_MYSQL_DATABASE");
09 April, 2013
PHP dynamic title
It is useful when you optimize you site for SEO, this tutorial will show you how to keep in one single page which you will include in all others, the dynamic titles script for different pages. We will need to make a variable to get the page, and put an switch & case feature to estabilish the title, then we’ll print the resulted title.
<?php
$page = $_SERVER['PHP_SELF'];
if(isset($page)) {
switch($page) {
case "index.php":
$title = "this is homepage";
break;
case "products":
$title = "products";
break;
case "contact":
$title = "contact";
break;
}
}else{
$title = "default title";
}
print "<title>$title</title>";
?>
Copy and paste it on your page header.
<?php
$page = $_SERVER['PHP_SELF'];
if(isset($page)) {
switch($page) {
case "index.php":
$title = "this is homepage";
break;
case "products":
$title = "products";
break;
case "contact":
$title = "contact";
break;
}
}else{
$title = "default title";
}
print "<title>$title</title>";
?>
Copy and paste it on your page header.
Subscribe to:
Comments (Atom)