...

View Full Version : Created a this or that website



Xaqa
05-01-2011, 01:18 AM
Ello there. So recently, I started to try and make a website and I've come up with the idea of showing two things and the viewer chooses which one they like better. I won't be too big, just local. But I'm having trouble coding this website.
What I was thinking is having the random images/videos in an array but when they click the button on which they like how do I get it to record the vote? And for the new generated one for like button should I just make it refresh? Anyways, thanks.

bullant
05-01-2011, 02:36 AM
.....when they click the button on which they like how do I get it to record the vote?

When they click the button, the id of the image associated with that button will need to be sent to the web server (with or without ajax). A server side script then increments a counter for that image either in a database of some kind or maybe just a plain text file.

Xaqa
05-01-2011, 03:36 PM
When they click the button, the id of the image associated with that button will need to be sent to the web server (with or without ajax). A server side script then increments a counter for that image either in a database of some kind or maybe just a plain text file.

And how might one go about doing so?

amitsh
05-01-2011, 04:56 PM
hey xaqa

u might be looking for something like this

http://www.hotscripts.com/listing/php-poll-with-images/

Xaqa
05-01-2011, 05:28 PM
Yes, something along those lines except I'm not going to pay 20$ for one. :P

bullant
05-01-2011, 10:48 PM
And how might one go about doing so?

One option is to append the id of the image as a query string to the url of the server side script.

If you post the code you have so far, we can try to help you get it working.

Xaqa
05-01-2011, 11:05 PM
<html>
<head>
<title>This.. or that!</title>
</head>
<body>
<h1>This or that - Pick one!</h1>
<?
$videos= array('<iframe width="425" height="350" src="http://www.youtube.com/embed/YgFyi74DVjc" frameborder="0" allowfullscreen></iframe>' );
$randvideo = array_rand($videos,1);
echo $videos[$randvideo];

?> &nbsp;&nbsp;&nbsp; <?
$videos= array('<iframe width="425" height="350" src="http://www.youtube.com/embed/N6O2ncUKvlg" frameborder="0" allowfullscreen></iframe>' );
$randvideo = array_rand($videos,1);
echo $videos[$randvideo];

?> &nbsp;
<p>Click your favourite!</p>
</body>
</html>

I haven't added barley anything. Not even the voting picture yet.

bullant
05-01-2011, 11:17 PM
ok, so you still need to add something for the users to click if they want to vote for an image and you also need to decide what type of database you will be using to store the votes.

But it appears you might be jumping ahead of yourself. When building a database driven website, it's usually better to first design and create the database and then build the front-end application (html/php/javascript).

The database is the foundations of your application and the front-end "sits on top" of your database.

Xaqa
05-01-2011, 11:27 PM
I have this I forgot to add:

(At top of page)


<?php
include("config.php");
?>

Then my config.php:


<?php
$hostname = "MY_HOSTNAME";
$db_username = "MY_USERNAME";
$db_password = "MY_PASSWORD";

$link = mysql_connect($hostname, $db_username, $db_password) or die("Cannot connect to the database");
mysql_select_db("DATABASE NAME") or die("Cannot select the database");


?>

Would work when connecting to MySQL database?

bullant
05-02-2011, 12:04 AM
Would work when connecting to MySQL database?

Did you get a connection when you ran that code?

Xaqa
05-02-2011, 12:14 AM
I'm not sure. But I have a new code. And it's here: http://www.technabled.com/2011/02/pulse-lite-reddit-ajax-up-down-voting.html

Unfortunatley I get many, many, errors when I load the webpage.

http://www.puddil.com/puddil/

I need help with Step 4-The End.

Could you give me an example or something.

bullant
05-02-2011, 12:22 AM
I'm not sure.

ok, it sounds like you are getting bits and pieces of code from various sources and need someone to put it together for you. There is a truckload of information and tutorials on the interweb that teaches how to do what you want rather than try to cobble together bits of code.

One place you could start at is the w3shools tutorials.

Xaqa
05-02-2011, 12:31 AM
I have the general codes, just I have no idea where to place them in my HTML.

bullant
05-02-2011, 12:35 AM
I have the general codes, just I have no idea where to place them in my HTML.
ok, no problem. But I wouldn't recommend doing it that way and it's not something I normally get involved in, so hopefully someone else will come along to help you.

amitsh
05-05-2011, 09:48 PM
dis is a link u may find helpful... it's a much easy one and most cool part is it uses flat file and blocka ip from re-voting...

but it requires lods of work as it's not ajax based which means results loads in new page..

but worth trying as u can add ajax quite easily...

http://www.dbscripts.net/poll/

cineweekly.com
05-05-2011, 10:30 PM
Yes, something along those lines except I'm not going to pay 20$ for one. :P

It's $25. Still can't believe people try selling stuff like this and fonts. Might as well go into the screensaver business.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum