WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 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
פרייסז - השוואת מחירים בסופר
ZeroLag.com
Texas Holdem Poker Evangelists

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 : A Simple Script to randomly select a CSS from MySQL
Categories : PHP, Databases, MySQL, CSS Click here to Update Your Picture
Vivek Ramnath
Date : Aug 30th 2004
Grade : 2 of 5 (graded 9 times)
Viewed : 7738
File : 4000.php
Images : No Images for this code example.
Search : More code by Vivek Ramnath
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

This script randomly selects a style sheet from the database and applies to the particular page !!!

CREATE TABLE `css` (
  `css_id` int(11) NOT NULL default '0',  //id of the style sheet
  `css_alias` varchar(100) NOT NULL default '', // alias for a style sheet
  `css_con` longtext NOT NULL,  //has the style sheet
  PRIMARY KEY  (`css_id`)
) TYPE=InnoDB;



<?php
$link
= mysql_connect("host", "uname","password")or die(" Start the DB Server");
mysql_select_db("user_reg") or die("Could not select database");
$r=rand(1,7);
setcookie ("st", $r,3600);
if(
strcasecmp(@$_COOKIE["logged"],"y")==0)
{
setcookie("logged","y",3600);
}
else
{
setcookie("logged","n",3600);
}
//print("<font face=Tahoma color=red size=4>".$r."</font><BR>");
if($r>0&&$r<8)
{
$query = "SELECT css_con FROM css where css_id='$r'";
$result = mysql_query($query) or die("Query failed");
header("Last-Modified:".gmdate("D,d M Y H:i:s")."GMT");
header("Expires :".gmdate("D,d M Y H:i:s")."GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
print(
"<html>");
print(
"<head>");
print(
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
print(
"<title>Welcome 2 WebcRaft</title>");
while (
$line = mysql_fetch_array($result, MYSQL_ASSOC))
        {
    foreach (
$line as $col_value)
        {
        print
"$col_value";
        }
        }
}
else
{
$query = "SELECT css_con FROM css where css_id=1";
$result = mysql_query($query) or die("Query failed");
while (
$line = mysql_fetch_array($result, MYSQL_ASSOC))
        {
    foreach (
$line as $col_value)
        {
        print
"$col_value";
        }
        }
}
?>
</head>
<body bgcolor="#000000" topmargin="10" leftmargin="10" marginheight="10" marginwidth="10" text="#FF0000" style="scrollbar-3dlight-color: #66FF00; scrollbar-arrow-color: #FF0000; scrollbar-base-color: #0000FF; scrollbar-darkshadow-color: #000000; scrollbar-face-color: #000000; scrollbar-highlight-color: #000000; scrollbar-shadow-color: #FFCCCC; scrollbar-track-color: #FF0000;" alink=#000000 vlink=#000000>
<?
$link
= mysql_connect("127.0.0.1", "root","vivek")or die("Could not connect");
mysql_select_db("user_reg") or die("Could not select database");
$q="SELECT css_con FROM css where css_id=8 AND css_alias='tabselect'";
$result = mysql_query($q) or die("Query failed");
$d=$_SERVER["REMOTE_ADDR"];
while (
$line = mysql_fetch_array($result, MYSQL_ASSOC))
        {
    foreach (
$line as $com)
        {
        print
"$com";
        }
        }
mysql_close($link);
if(
strcasecmp(@$_COOKIE["logged"],"y")==0)
{
print(
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\"  width=\"100%\" >");
print(
"<tr><td width=\"100%\" align =left>");
print(
"<font face=Exocet color=#33CC00 size=3>Your ip address is :</font><font face=Exocet color=#CCFFFF size=3> $d</font>");
print(
"</td><td width=\"80%\" height=\"100%\"><a href=\"./mysql_lgout.php\"><img src=\"logout.gif\" align=right height=21 width=68 ></a></td></tr></table>");

}
else
{
print(
"<div>");
print(
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\"  width=\"100%\">");
print(
"<tr><td width=\"100%\">");
print(
"<p align=right><font face=Exocet color=#33CC00 size=3>Your ip address is :</font><font face=Exocet color=#CCFFFF size=3> $d</font></p>");
print(
"</td></tr></table>");
print(
"</div>");
}
?>
</p>
</div>
<?
print("<marquee behavior=\"scroll\" direction=\"left\">");
$link = mysql_connect("127.0.0.1", "root","vivek")or die("Could not connect");
mysql_select_db("user_reg") or die("Could not select database");
$fet="SELECT news_id,news_head FROM news  ";
$result = mysql_query($fet) or die("Query failed");
for(
$i=0;$i<mysql_num_rows($result);$i++)
{
$row=mysql_fetch_assoc($result);
$head=$row["news_head"];
$id=$row["news_id"];
  print(
"<a href=\"./news.php#".$id."\"><img src=sidearr.gif><font face=\"Comic Sans\" color=\"Yellow\">$head</font></a>");
   
       
}   
print(
"</marquee>");
?>
<p align =center>
</p>                                                                                                                  
<?
if(strcasecmp(@$_COOKIE["logged"],"n")==0)
{
print(
"<P><font  face=Bookman Old Style >REGISTERED GUYZ PLEASE LOGIN </font><A HREF=\"login.htm\"><font  face=Bookman Old Style color=blue>HERE</font></A></P>");
print(
"<p><font  face=Bookman Old Style >NEW USER???.CLICK </font><a href=\"reg_form.php\"><font color=blue>HERE</font></A></p>   ");
}
else
{
    print(
"  ");
}
?>
</center>
</FORM>
</BODY>
</HTML>



bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, Databases
This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server.
Categories : Databases, MySQL, Complete Programs, PHP, Databases
Finds the median in an array of numbers - Can be used with a MySql database column read into an array
Categories : PHP, Arrays, Databases, MySQL
AJAX Application
Categories : PHP, AJAX, Databases, MySQL
A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Categories : PHP, PHP Classes, Databases, MySQL, HTML and PHP
AITSH Download
Categories : PHP, Complete Programs, MySQL, Databases
A very simple and efficient split bar the B-Z bar , for mysql and php ... Tired of obfuscated code try this one ...
Categories : PHP, Databases, MySQL, Algorithms
DDN FFA Network Script
Categories : PHP, MySQL, Complete Programs, HTML and PHP, Databases
How to thread a list of messages in database and show it in a treelike structure
Categories : PHP, MySQL, Databases
Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields
Categories : MySQL, Date Time, PHP, Databases
Paginating the mySQL data
Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP
php-gtk mysql querying tool
Categories : PHP-GTK, MySQL, PHP, Databases
XDT Topsite (Gold v1.0)
Categories : Databases, CSS, PHP, HTML and PHP, Sessions
Multiple Search using PHP and Mysql
Categories : PHP, Databases, General SQL, MySQL
Web Self Service Resource Scheduler Using Session Variables under php4 includes Calendar building code - requires MySQL
Categories : PHP, Complete Programs, Calendar, MySQL, Databases