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
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
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 widget for presenting color options in a drop down menu
Categories : HTML, PHP Update Picture
Paul Meagher
Date : Jan 17th 1999
Grade : 2 of 5 (graded 6 times)
Viewed : 6091
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Paul Meagher
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<HTML>
<TITLE>Color Selector Widget</TITLE>
<BODY>

<?

/*
Script Name: color_drop.html

Script Purpose: A widget for presenting color options in
a drop down menu.

Script Author: Paul D. Meagher (meagher@mallnetglobal.com).

Copyright: Open Source Freeware.

Demo: http://www.mallnetglobal.com/colors/color_drop.html

Script Setup: This script draws color information
(color name, color code) from a MySQL database and presents
it to the user as a drop down menu of color terms.
There are many situations in which you will want to allow
people to control the color of some object by selecting its
color. In this example, I want to allow the person
to control the color of text.

You will need to create a database and insert color names
and associated rgb values into it. I have developed a php3
script that facilitates entry of new color terms and values,
but it is not yet ready for release. This might be overkill
as it is probably easier to load a text file of mysql inserts.

Here is the table schema that I am using.

CREATE TABLE colors (
uid MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
color_name VARCHAR(50),
color_code VARCHAR(10),
PRIMARY KEY(uid)
);

The program also maintains state information about the color
previously selected. If this program is passed the variable
text_color, it will present its value as the currently selected
item in the drop down box.

*/

/* Declare some variables. */

$hostname = "localhost";
$password = "";
$user = "ftp";
$database = "colors_db";
$table = "colors";

/* Main Loop */

echo "The text will look link this <font color=\"$text_color\">Sample</font> <br>";

mysql_connect($hosthame,$user,$password);
$result = mysql($database, "SELECT distinct color_name,color_code FROM $table ORDER BY color_name");
$num_cols = mysql_numrows($result);
$counter = 0;
echo "<FORM METHOD = \"POST\" ACTION=\"color_drop.html\">\n";
echo "<select name=\"text_color\">\n";
if ($text_color == "") {
echo "<option selected>Select Color...\n" ;
};
while($counter < $num_cols):
$cn = @mysql_result($result,$counter, "color_name");
$cc = @mysql_result($result,$counter, "color_code");
if ($text_color == $cc) {
echo "<option value=\"$cc\" selected>$cn\n" ;
} else {
echo "<option value=\"$cc\">$cn\n" ;
};
$counter = $counter + 1;
endwhile;
echo "</select>\n";
echo "<INPUT TYPE=\"submit\" VALUE=\"View Color\">\n";
echo "</FORM>\n";
?>
</BODY>
</HTML>



Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Paginator - a class that can help you to split MySQL database query result sets to pages.
Categories : MySQL, Databases, HTML, PHP
Browser Detecor Class
Categories : PHP Classes, PHP, HTML
How to get the source of a site into an array.
Categories : Arrays, HTML, PHP
Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance.
Categories : HTML, PHP, HTML and PHP, Beginner Guides
GonxTabs : Create elegant HTML tabs based interface
Categories : Navigation, HTML, HTML and PHP, PHP
Display Slashdot headers on your own site
Categories : HTML and PHP, HTML, PHP
Form is a utility class for generating html forms. It provides form initialization and regex based data validation (both server and client side) with a convenient interface. This version obsoletes version 1.0a
Categories : HTML, PHP, PHP Classes, Regexps
class formHTML build your HTML Forms from PHP
Categories : PHP, PHP Classes, HTML and PHP, HTML
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but effective.
Categories : PHP, PHP Classes, HTML, HTML and PHP
Script to check values being submitted by POST or GET method from a form. This script may help diagnose what variables are being supplied by a browser to other php scripts.
Categories : HTML, Variables, Debugging, PHP, HTTP
color codes for positive and negative numbers
Categories : PHP, MySQL, Databases, HTML
Formit 1.0. PHP Very easy to implement form-template(s) to email script. Works with multiple templates and HTML-format email. Only one file!
Categories : PHP, Email, HTML
This script shows you the 7th latest php items from the mailing list archive on zend.com
Categories : HTML, HTML and PHP, HTTP, PHP