WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Unique Title Description and Keywords for Template Engine
Categories : PHP, Search Engines Click here to Update Your Picture
Kevin O'Neil
Date : Jul 14th 2004
Grade : 4 of 5 (graded 6 times)
Viewed : 2805
File : 3934.php
Images : No Images for this code example.
Search : More code by Kevin O'Neil
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

This page is what I came up with on how to add title, keywords and description capabilities to a template engine.I have this on my website.

First I use url_array so that my pages are search engine optimized. The query appears after the index.php part of my url. (Actually it's just index/ because I have it set up so that I don't need to include the .php in the url). My default is http://www.kevinslair.com/index/Rider+Waite+Tarot+Cards

The document calling the url_array is usually 0. Then you list each array after this in sequence. Like 0,1,2,3... ect.

If you have multiple arrays that require additions, I write them down to keep track of them.

Example: yourpage.php?this=that&animal=cat&page=html&you=there would be urled as:
        yourpage.php/that/cat/html/there

I use urlencode() and urldecode() to make it easier for calling the script as it's own "leftlinks" hyperlinks.

urlencode() will turn "Hello You" into "Hello+You" and urldecode() will turn "Hello+You" to "Hello You".

This makes it easier to set up the datafile and keep track of title, keywords and descriptions.

This is how you set up your head datafile for a MySql database:



Run Sql in phpmyadmin to create the table "sitedata". This is where the keywords, description and query are kept.

"sitepost" is the SEO query in my url. "yourpage.php/This+Code+Here" except you do not put the "+" (Plus sign) in here.
"sitevar" is the query you want to perform in your product table query.
"keywords" are the keywords that you want to use to describe your page.
"description" same as keywords except this is more of a statement.
"title" This is the unique title for the page.

CREATE TABLE sitedata (
  sitepost blob,
  sitevar blob,
  title blob,
  keywords blob,
  description blob

) TYPE=MyISAM;

#
# Dumping data for table `sitedata`
#

INSERT INTO sitedata VALUES ('Url Link', 'catagory LIKE \'%description one%\'', 'keywords', 'description');
INSERT INTO sitedata VALUES ('Url Link 2', 'catagory LIKE \'%description two%\'', 'keywords', 'description');




The reason I have them all "blob" is because I sometimes have a lot of info on each product or product line and it helps with preparing the database for the drive home.

The "catagory LIKE \'%value%\'" is generic. I will talk more about this later.

This is how the contents of your catalog is querried. Don't forget if you are using '||' to seperate query on the same line, you can use this here as well. Example: "catagory LIKE \'%value%\' || item_number = \'%value2%\'".


The first column of your new table is how you want the link to look. An example would be as above "Url Link".

In your Left Links you would use yourpage.php/Url+Link This will query the table sitedata in column sitepost for the data of "Url Link". It's very specific when you don't use the % (Percent Sign) Before or After the query.



<?php

   
//This was explained above. This is so you don't have to use "?dataone=answer" after the document.

   
$url_array = explode("/",$PATH_INFO);

   
//This array is how you query the database. Remember, multiple query are called in sequence.
    //An example would be:
    // "yourpage.php" = $url_array[0];
    //$urlkey = $url_array[1];
    //$datatwo = $url_array[2];
   

   
$urlkey = $url_array[1];

   
//I put this in so that if you go directly to the index.php page without using navigation, it will display a default     //page. Just don't forget to include "+" (Plus sign) here.

   
if(!$urlkey) {

   
$urlkey = "Url+Link+2";

    }

?>


<?php


   
// urldecode() will remove the "+" (Plus sign) from your query.
   
$sitekey = urldecode($urlkey);

   
$db = mysql_connect("host", "username", "password") or DIE(mysql_error());

   
mysql_select_db("database");

       
$result = mysql_query("SELECT * FROM sitedata WHERE sitepost LIKE '$sitekey'") or die(mysql_error());

    while(
$row = mysql_fetch_array($result)) {

   
extract($row);

   
$sitevar = $row["sitevar"];
   
$sitepost = $row["sitepost"];
   
$description = $row["description"];
   
$keywords = $row["keywords"];

    }

//I use $var as the actual query for the product table. This is very helpful and cuts down on coding.
$var=$sitevar;


echo
'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>'
. "$sitekey" . ' or You can create custom titles and make new column called "title"</title>
<meta NAME ="DESCRIPTION" CONTENT="'
. "$description" . '">
<meta NAME ="KEYWORDS" CONTENT="'
. "$keywords" . '">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META NAME="Language" CONTENT="en-us">
<META http-equiv="Expires" CONTENT="Thu, 04 Oct 2100 14:21:20 GMT">
<META NAME="Revisit-After" CONTENT="10 Days">
<META NAME="Distribution" CONTENT="Global">
<META NAME="Robots" CONTENT="All">
<link rel="shortcut icon" href="http://www.yoursite.com/favicon.ico">
</head>
'
;

?>


I would use the above head in your template engine to create unique pages without the headache of actually creating them.

In the index.php page where I have the query to the product table, I have it coded like this:

$result = mysql_query("SELECT * FROM products WHERE $var ORDER BY item_number") or die(mysql_error());


That's not the actual result but it's close. I won't put the actual result here.
This is generic to my site. You can customize to fit your needs.

How do I create the left links?

http://www.yoursite.com/yourpage.php/Your+Code+here

-OR-

You can create the left links navigation on the fly using the example above:

This will be your "left link navigation" page:

<?php

    $db
= mysql_connect("host", "username", "password") or DIE(mysql_error());

   
mysql_select_db("database");

       
$result = mysql_query("SELECT * FROM sitedata") or die(mysql_error());

    while(
$row = mysql_fetch_array($result)) {

   
extract($row);

   
$sitepost = $row["sitepost"];

   
//Remember that urlencode() will add a "+" (Plus sign) to your sitepost.
   
$sitepost2 = urlencode($sitepost);

    echo'
<a href="http://www.yoursite.com/yourpage.php/$sitepost2">$sitepost</a><br>";
   

    }

    //This will display all your left link navigation here.
?>


I have a whole lot more, but will have to make a new example page for it. I created this because I couldn't purchase a script to do what I was looking for.

I hope this helps at least one person who is having trouble creating unique title, description and keywords for their template engine.

Thanks,
Kevin



Boolean Keyword Interpreter
Categories : PHP, Algorithms, Search Engines
UDMSearch - a free search engine, indexing system.
Categories : Search Engines, Linux, PHP, MySQL, ODBC
SubmitForce URL power submitter (searchengine submission class)
Categories : PHP, Search Engines, URLs, PHP Classes
How to build a search query for any N number of words in a search string
Categories : PHP, Regexps, Search Engines, Search
Sitmap Generator PHP class
Categories : PHP, PHP Classes, Search Engines, Site Planning
Dynamic pages with no "?"
Categories : PHP, Search Engines
SiteSearch 1.1: This app lets end users search your site for keywords. You specify which directories should be included in the search.
Categories : Search, Search Engines, PHP
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
PageRank Display
Categories : Search Engines, HTML and PHP, PHP
http://phpMySearch.web4.hm - The phpMySearch search engine system is a completeworld wide web indexing and searching system for a small domain or intranet.
Categories : Search Engines, PHP, Databases, MySQL
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
PHP Script to find url links in a page
Categories : PHP, URLs, Regexps, Arrays
Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
very simple ftp class
Categories : PHP, PHP Classes, FTP
PHP Paypal IPN Integration Class v1.0.0
Categories : PHP, PHP Classes, Payment Gateways