OK, I am going to preface this with the warning that my code skills are really rudimentary--I've cobbled together what I can, but my lack of experience with Javascript is keeping me from implementing this final thing. I have my page set up: http://excitable.media/reddit.php
It is almost doing what I want. The arrows are changing on click with the CSS. The Big number is being called from an SQL Database, in a table named votes
that has only one column--count
. What I want to happen now is that when someone clicks the up arrow, the count entry is increased by one and the vote count on the page is updated. I know I need AJAX/JQuery to do this, but once again, even the syntax is difficult for me. Here is the page code right now:
<html>
<head>
<meta charset="utf-8">
<title>Reddit</title>
<link rel="stylesheet" type="text/css" href="css/css/reddit.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="css/js/reddit.js"></script>
</head>
<body>
<h1>reddit</h1>
<div class="container">
<div class="up">
<input id="img-switcher" type="checkbox"></input>
<label for="img-switcher"></label>
</div>
<div class="count" id="vote-value">
<?php
include '../php/config.php';
$con;
$dbhandle;
$selected;
if($vote)
echo $vote[0];
?>
</div>
<div class="essay">
<p>Registering an account with Reddit [paragraph text omitted]</p>
</div>
<div="down">
<input id="img-switcher-2" type="checkbox"></input>
<label for="img-switcher-2"></label>
</div>
</div>
</body>
</html>
Can anyone help me with this rudimentary coding project? I have another php file called 'insert.php' that connects to the database and then says:
$update=mysql_query("UPDATE 'votes' SET 'count'='count'+1)");
if(mysql_query($update)){
return "success!";
}
else {
return "failed!";
}
The reddit.js file is totally empty right now, it's where I am expecting to place the code to make this work. It's also worth mentioning that I don't care about the down arrow at all. I don't want it to function. I only want the up arrow to work. I don't care if people click it more than once from the same IP.