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
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 : Example voting script. Lets people enter suggestions and vote for existing ones.
Categories : MySQL, PHP, Cookies, Complete Programs, Databases Update Picture
vote.php3 lerdorf
Date : Aug 07th 1998
Grade : 3 of 5 (graded 8 times)
Viewed : 19728
File : No file for this code example.
Images : No Images for this code example.
Search : More code by vote.php3 lerdorf
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

/*
* Vote Example Script
*
* You can see it in action at http://www.lerdorf.on.ca/nameit.php3
* and you can also get the associated image files there.
*
* The MySQL schema that goes along with this is:
* CREATE TABLE names (
* name varchar(30) DEFAULT '' NOT NULL,
* votes int(4),
* PRIMARY KEY (name)
* );
*/
<? if($vote && !$already_voted) SetCookie("already_voted","1");?>
<html><head><title>Name the Baby Computer</title></head>
<body bgcolor="#ffffff" text="#032F5B" link="#537492" vlink="#000000">
<FONT FACE="Verdana, Arial, Helvetica">
<h3>Name the new baby</h3>
I will be getting a cute little <a
href="http://www.corelcomputer.com">NetWinder</a><img src="tm.gif">
box to stick on my LAN at home soon. It needs a name.
<b><i>something</i></b>.lerdorf.on.ca<p>

Please give me some suggestions or vote for an existing one.
</font>
<form action="vote.php3" method="POST">
Suggestion: <input type=text name=new_name size=25 maxlength=29><P>
<input type=submit value="Submit suggestion and/or vote">
<input type=reset><P>
<?
mysql_pconnect("localhost","","");

if($new_name) {
if(!mysql_db_query("rasmus","insert into names values
('$new_name',0)")) {
print mysql_errno().": ".mysql_error()."<BR>";
}
}
if($vote && $already_voted) {
print "<font color=#ff0000>Hey, you voted already! Vote
ignored.</font><P>\n";
}
else if($vote) {
if(!mysql_db_query("rasmus","update names set votes=votes+1 where
name='$vote'")) {
print mysql_errno().": ".mysql_error()."<BR>";
}
}
$result=mysql_db_query("rasmus","select sum(votes) as sum from names");
if($result) {
$sum = (int) mysql_result($result,0,"sum");
mysql_free_result($result);
}

$result=mysql_db_query("rasmus","select * from names order by votes DESC");
print "<table border=0><tr><th>Vote</th><th>Suggestion</th><th
colspan=2>Votes</th></tr>\n";
while($row=mysql_fetch_row($result)) {
print "<tr><td align=center><input type=radio name=vote value=\"$row[0]
\"></td><td>";
print $row[0]."</td><td align=right>".$row[1]."</td><td>";
if($sum && (int)$row[1]) {
$per = (int)(100 * $row[1]/$sum);
print "<img src=bline.gif height=12 width=$per> $per %</td>";
}
print "</tr>\n";
}
print "</table>\n";
mysql_free_result($result);
?>
<input type=submit value="Submit suggestion and/or vote">
<input type=reset>
</form>
<a href="http://ca.php.net"><img align=top src="php3/logos/mini-logo1.gif"
border=0></a>
<tt><font size=-1><a href="nameit.phps">View Source</a></font></tt>
</body></html>



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
bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, Databases
Tropicalm Genetree Family (MySQL based family tree)
Categories : PHP, Interfaces, Databases, MySQL, Complete Programs
This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change
Categories : PHP, Arrays, Cookies, MySQL, 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
Shopping Basket On-Line Ordering System.
Categories : Complete Programs, MySQL, PHP, Ecommerce, Databases
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
free, search engine, indexing, system, information, web, ftp, http, free, software, cgi, php, MySQL, database, php3, FreeBSD, Linux, Unix, UdmSearch
Categories : MySQL, Complete Programs, PHP, Databases, Search
Shopping Cart e-Commerce Solution
Categories : Complete Programs, PHP, MySQL, Databases
complete, simple, working example of a login screen/system using php functions, cookies, and a mysql database for begginers.
Categories : Authentication, Complete Programs, PHP, MySQL, Databases
BBS system for easy customization. Utilizes mySQL.
Categories : Complete Programs, MySQL, PHP, Databases
AITSH Download
Categories : PHP, Complete Programs, MySQL, Databases