Posts

Showing posts from April 24, 2010

reddit style voting in php mysql jquery

Image
This tutorial will show you how to create such a voting system with jQuery, PHP and MySQL. I created a table called entries where there are 5 columns: id — The unique id associated with each entry title — The title of the entry to be shown as a link to the site votes_up — The total number of people who voted up. votes_down — The total number of people who voted down. Fetch The Data Now, we have the table and the data. Let's show the data. We create a config.php file that holds all our database credentials. <? $hostname = "localhost"; $db_username = "your_username"; $db_password = "your_password"; $db_password = "your_database"; $link = mysql_connect($hostname, $db_username, $db_password) or die("Cannot connect to the database"); mysql_select_db($db_password) or die("Cannot select the database"); ?> What we did is just connect to the database. Do replace your_username, your_password and your_datab...