server-php-sqlite-voting.php / php
<?php header ("Content-type: image/png"); red = imagecolorallocate (black = imagecolorallocate (
db = new SQLiteDatabase("server-php-sqlite-voting.db"); /* db->query("BEGIN; CREATE TABLE poll (id INTEGER PRIMARY KEY, vote CHAR(20)); INSERT INTO poll (vote) VALUES('hat'); INSERT INTO poll (vote) VALUES('hat'); INSERT INTO poll (vote) VALUES('shirt'); INSERT INTO poll (vote) VALUES('mug'); INSERT INTO poll (vote) VALUES('hat'); INSERT INTO poll (vote) VALUES('hat'); COMMIT;"); */
db->query("SELECT * FROM voteoptions"); optionsquery->numRows(); db->query("SELECT * FROM poll"); pollquery->numRows();
barwidth = floor(300/i=0;numoptions-1);entry = voteoption = i]['name']; voteoption; //sqlite_result(i,'name'); db->query("SELECT * FROM poll WHERE vote='currentnum = per = floor((currentnum/numvotes)*184); currentnum/numvotes)*100); imagefilledrectangle (im, per), (barwidth), 200, im, per), (barwidth), 200, im, 1, (barwidth/2)), 205, black); imagestring (xval+(per)-15), "black); barwidth+10); }
imagepng(im,'voting-plot.png'); // echo '<center>'; // echo '<img src=voting-plot.png width=100% height=100%>'; // echo '</center>'; ?>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.