|
|
|
/*
* 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 | |
|
|
|