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 : MyRedirector 1.0 is a Redirector with graphical Statistics
Categories : HTTP, Complete Programs, MySQL, URLs Update Picture
Mark Kronsbein
Date : Jun 29th 1999
Grade : 2 of 5 (graded 1 times)
Viewed : 6182
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Mark Kronsbein
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
//////////////////////////////////////////////////
// MyRedirector Version 1.0
// Redirector
// redirect.php3
// Written by Mark Kronsbein
// License: GPL
// I only ask that you to NOT delete the credit!
// Please mail me at mk@html-design.com
// if you use this Script! Thanx!
// See it in Action at http://www.gabber.de
//
// Installation:
// Insert your Values for $hostname, $username,
// $password, $userstable and $dbName and $host.
// Call it like
// redirect.php3?url=http://www.hostname.de
//////////////////////////////////////////////////

$host = "http://www.hostname.de/";
$hostname = "localhost";
$username = "your-username";
$password = "your-password";
$userstable = "redirect";
$dbName = "your-db-name";

if ($url != $host){
MYSQL_CONNECT($hostname, $username, $password) OR DIE(mysqlerror());
@mysql_select_db( "$dbName") or die(mysqlerror());
$query = mysql_fetch_row(mysql_query( "select * from $userstable where(url = '$url')"));

if ($query == false){
$hits = "1";
$query2 = "INSERT INTO $userstable (url,hits) VALUES('$url','$hits')";
}
else {
$hitquery = "select hits from $userstable where url = '$url'";
$result = mysql_query($hitquery);
$hits = mysql_result($result, 0, "hits");
$query2 = "update $userstable set hits = hits+1 where url = '$url'";
}

MYSQL_QUERY($query2);
}
if(!$url) {
$url = "$host";
}
else {
Header( "Location: $url");
}
?>
<?
//////////////////////////////////////////////////
// MyRedirector Version 1.0
// Stats-Viewer
// viewstats.php3
// Written by Mark Kronsbein
// License: GPL
// I only ask that you to NOT delete the credit!
// Please mail me at mk@html-design.com
// if you use this Script! Thanx!
// See it in Action at http://www.gabber.de
//
// Installation:
// Insert your Values for $hostname, $username,
// $password, $userstable and $dbName.
//////////////////////////////////////////////////

$hostname = "localhost";
$username = "your-username";
$password = "your-password";
$userstable = "redirect";
$dbName = "your-db-name";

$color10 = "#FFFF00"; /* Color for Hits between 1 and 9 */
$color20 = "#FF0000"; /* Color for Hits between 10 and 19 */
$color50 = "#008000"; /* Color for Hits between 20 and 49 */
$color1k = "#0000FF"; /* Color for Hits between 50 and 99 */
$color2k = "#0000A0"; /* Color for Hits between 100 and 199 */
$color5k = "#000040"; /* Color for Hits over 200*/

MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
@mysql_select_db( "$dbName") or die( "Unable to select database");
$query = "select * from $userstable order by hits desc";
$result = MYSQL_QUERY($query);
$number = MYSQL_NUMROWS($result) or die (mysql_error());

$i = 0;

IF ($number == 0) {
PRINT "<CENTER><P><b>No Links tracked yet!</b></CENTER>";
}
ELSEIF ($number >= 1) {
WHILE ($i < $number){
$hits = mysql_result($result,$i,hits);
$url = mysql_result($result,$i,url);
if ($hits < 10){
$color = "$color10";
}
elseif (($hits >= 10 ) AND ($hits < 20)){
$color = "$color20";
}
elseif (($hits >= 20 ) AND ($hits < 50)){
$color = "$color50";
}
elseif (($hits >= 50 ) AND ($hits < 100)){
$color = "$color1k";
}
elseif (($hits >= 100 ) AND ($hits < 200)){
$color = "$color2k";
}
elseif ($hits >= 200){
$color = "$color5k";
}
PRINT "<div align=\"left\">";
print "<table COLS=3 border=\"0\" width=\"100%\"><tr><td ALIGN=LEFT with=\"400\"><b><a
href=\"$url\">$url</a></b></td>";
print "<td ALIGN=right WIDTH=\"60\"><b>$hits</b></td>";
print "<td align=left WIDTH=\"$hits\" BGCOLOR=\"$color\">&nbsp;</td></tr>";
$i++;
PRINT "</table>\n";
}
}
?>

#
# MyRedirect.sql
#

CREATE TABLE redirect (
url varchar(100) NOT NULL,
hits int(10) DEFAULT '0' NOT NULL,
PRIMARY KEY (url)
);



phpHoo2 (Xhoo using php3/MySQL) is a Yahoo-like link directory. Much like the Open Directory Project (dmoz.org).
Categories : PHP, Complete Programs, Directories, MySQL, URLs
bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, Databases
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
phpAds, a complete banner and ad management system with detailled tracking and stats.
Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases
Point and Click Interface ala MS Access for creating SQL statements.
Categories : MySQL, Complete Programs, General SQL, PHP, Databases
phpCards - PHP/mySQL postcard script with web based admin to add, edit, and delete cards and categories. Very easy to install.
Categories : PHP, Complete Programs, HTML and PHP, MySQL
Tropicalm Genetree Family (MySQL based family tree)
Categories : PHP, Interfaces, Databases, MySQL, Complete Programs
Web Self Service Resource Scheduler Using php3 and MySQL
Categories : PHP, Complete Programs, MySQL
Shopping Basket On-Line Ordering System.
Categories : Complete Programs, MySQL, PHP, Ecommerce, Databases
Example voting script. Lets people enter suggestions and vote for existing ones.
Categories : MySQL, PHP, Cookies, Complete Programs, Databases
Free For All Links Page using PHP3 and Mysql
Categories : PHP, MySQL, Complete Programs
fforum fumanchi forum MySQL treestructure
Categories : Complete Programs, PHP, MySQL
Simple pipe delimited file export program that downloads to a local machine
Categories : PHP, Filesystem, Databases, MySQL, HTTP
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
Browse a MySQL database & draw a tree view & load final items into a template page.
Categories : MySQL, Complete Programs, Algorithms, PHP, Databases