|
| |
|
EBooks » Web Tutorials
Search Engine Optimization By Brad Callen MADE EASY CONTENTS Chapter 1 "Optimize The Wrong Keywords And You'll Likely Never See Results ...” "How Changing One Single Onpage Optimization Factor Can Boost Your Rankings By Over 350 Positions!" "The Secret To Getting Listed In Google In Under 24 Hours - Guaranteed!” "How To Skyrocket Your Website To The Top Of Google With Properly Planned Offpage Optimization!" "How To Skyrocket Past The #1 Ranked Website On Google For The Term Diet Information ..." "Are You Asking Google To Penalize Or Ban Your Website?” "Don't Get Your Website Banned BY Google... By Accident!” "Possibly The Biggest Misconception About Ranking Well In The Search Engines...” "What You Must Do To Rank Well For Your Inner Web Pages...” Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Quick Summary Chapter 8 Chapter 9 Chapter 10 "The Cold Hard Facts About Google Page Rank And How To Use It To 1-Up Your Competitors This course will provide in-depth coverage of major PHP syntax, built-in functions of PHP, web application programming techniques and recommended coding solutions based on common PHP requirements. The user will also learn how to create a complete web application using HTML/XHTML/XML, Javascript, Postgres/SQL and then learn to troubleshoot by example. Examples and code for an online card game, shopping cart, email newsletter, content management system and online survey system, are included within the tutorial
This article will teach you how to write a basic poll script in php. You will mysql and a new version of PHP.
The first step is to create a database that will hold the information
all the polls we want. For this article we will be creating a poll that
will have 3 options. Yes, No, and Not Sure. So we will want to create
feilds for each of those. I used Option1, Option2, and Option. We will
also need a title and a question to ask. I created those as varchars.
Another feild will hold the total number of votes total. The most
important colum is the ID colum which will be an auto increment tinyint
that will help use to select, edit, and add new records. Here is the
schema of my table: This tutorial aplies to anything like
page.php?var=stuff&var2=stuff. Let me define a few terms to start:
'query string' is the ?page=blah part in 'page.php?page=blah'.
page=blah is called a variable=value pair. You can seperate them by
doing 'page.php?var1=bob&var2=tom'.
Now, something that will cause many of you problems is
register_globals. If its off (which it is by default in the last few
php distrubs), using $queryStringVar when going to
page.php?queryStringVar=tom wont print out anything. In fact, chances
are it will give you an unset / undefined variable error... whcih isnt
good! But we have a soultion.
Remember the variable=value pairs? We can get things from the query
string through the $_GET array, no matter what. So since
$queryStringVar doesnt work, we have to get it through
$_GET['queryStringVar']. Ever wanted to learn how to do that? Loading pages through the index?
Well I will teach you how to do it a good way, fast and secure. The way this counter works is it creates a cookie on the user's
computer with their IP and it updates the count according to the status
of that cookie. If the cookie is present and the IP in the cookie is
the same as the user's current IP then the script knows the user has
already been there and it does nothing or if it is present, but has an
IP different than the user's current IP or is not present the script
knows that the user is either new or was there before, but the cookie
has expired so it then updates the count. This script will be using the
setcookie()
function, which must be sent before any headers are sent. Basically
what that means is that it must be placed before any HTML. The count
will be held in a text file for ease of use but if you desire to use a
database that is perfectly acceptable.
This is for my friend from Morroco
Introduction
This tutorial is designed to guide you through the logic and code behind the
process of paginating data in PHP. In this tutorial, the data is retrieved from
mySQL database. I feel you will be able to grasp this tutorial better if you have
a decent knowlege of PHP and mySQL. However, I plan to comment code as much as
possible and describe the why we do each part.
What is Pagination?
There might be a few of you who are clueless to even what pagination is. For
those with question, pagination is where you have more data that desired appearing
on one page, and breaking up that data so that it is then presented on multiple pages.
It is very likely that you have seen this before. Maybe you notice at the very bottom of some sites, the page numbers are listed and either "Previous" or "Next" to
the left and right.
This is a simple random image script which is ideal
for displaying basic images from a text file . In future
examples we will expand on this and build some simple
banner rotation systems.
The first step that you need to do is to create your
file for storing your images and then insert the names
of the images.
In the example here I called the file images1.txt .
Each one of the entries is on a seperate line and in
this case because I stored the files in a sub-directory
I inserted that also . the structure of the file was
like this
image/banner1.gif
image/banner2.gif
image/banner3.gif
and so on. Now we get to the script that will display
a random image and again this is straight forward enough. It's the Information age, and information can't be contained, it grows by the second. Hence no
single site can suffice the needs of today's visitor be it Yahoo! or any other site. Internet is
a whole new medium and tracking of 100's of portal start ups is annoying, but still you wander
about here and there. Agreed that bookmarks make life much simpler, but easier hmm...
Today I'll discuss how to grab stuff from all these happening places, I'll take the example of
Yahoo! NewsPod, probably the most successful script for grabbing news from Yahoo!
The base methodology behind "grabbing" content is RegEx, which allows you to grab a certain
portion of the obtained content.
Linear Working :
(1) A socket (behind the scenes) connection to http://www.yahoo.com/index.html
(2) Reading a pre-determined (or filesize determined) bytes of the page and storing into array
(3) Searching for particulars and storing into another variable
(4) Sorting out further for extra customization There are many situations where you might want to display up-to-date information
on your website. I will use the process of displaying the latest headlines from Slashdot.org
as an example here.
Getting the headlines
The file http://slashdot.org/slashdot.xml
contains the current slashdot headlines for people to use on their websites. You could
just load the data from this file every time someone visits your page. However, Slashdot requests
that you only access the file once every 30 minutes or more (to reduce the load on their server).
This means we will need a better strategy for making sure we have up-to-date headlines.
You could use cron to perform the update once every 30 minutes but for various reasons this
might not be possible. My approach is to write a PHP script that does the following when a user loads
the page with the dynamic content:
1. Check whether a local (i.e. on my webserver) copy of slashdot.xml has been updated
within a predefined time period (more than 30 mins in this case).
2. If it has not been updated recently enough then download the current one from
slashdot.org.
3. Display the data from the local copy of slashdot.xml.
|
| |
|