Whats Better Script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

timka
Forum Commoner
Posts: 26
Joined: Sat Feb 14, 2004 5:11 pm

Whats Better Script

Post by timka »

Hello Im new here, and I was looking for this one scripts for few months now with out any luck, I don't really know the name of the script, but u can see the example at http://www.whatsbetter.com or http://www.bootyvote.com 18+ if anyone knows the name of the script or knows where can I download it please help me out. I relly need this script and I've lost any hope on other boards so I came to PHP proffecionals with one last hope. :oops: :cry:
timka
Forum Commoner
Posts: 26
Joined: Sat Feb 14, 2004 5:11 pm

Post by timka »

It doesn't have to be a fancy one all I want is people to vote between two images for a better one.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

http://www.hotscripts.com

you beat me :P DUFF
timka
Forum Commoner
Posts: 26
Joined: Sat Feb 14, 2004 5:11 pm

Post by timka »

did u guys looked at examples I need something like that where u get to choose one picture from two. and I've looked all over hotscripts.com I looked before I asked.
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

We can help you with the script, but you will have to have the determination to learn php on your own to achieve this. This is not a difficult script, but to try to get something like this working when you have no knowledge of PHP then that's a different story.
timka
Forum Commoner
Posts: 26
Joined: Sat Feb 14, 2004 5:11 pm

Post by timka »

Im willing to learn. im very new with php.
Please help me find the script I've looked every were I could. PLEASE
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

I don't know of any scripts out there. But this seems like a minor thing, that i would prefer to code myself.

I can point you in the right direction.
First you probably want to set up a database. This is your base data structure, everything will be stored here.

Now, you need a basic page where you show two pictures.
Whatever you choose, then a field (radio button) within a <POST> field.

You will catch the <POST> variables to determine which radio button has been pressed, and from that, you load the result in the database.

Then you will have to decide some way to block the person from voting again, or you don't care.

Once you have done this, you will have to think about how you are going to manage many of these voting pictures processes.

Now, it's all about figuring out what you need, and how to implement it.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

It's just a basic voting script, using links instead of forms, and only two options.

img 1 links to: site.com/page.php?id=54&vote=1
img 2 links to: site.com/page.php?id=54&vote=2

This just says "hey page, this is the 54th poll, and they voted for number $vote!"

if its 1, it increments the db value for 1.. well.. +1
if its 2, it increments the db value for 2, +1

the front page is probably a random poll?

just use the random function with mysql_num_rows as the highest number
timka
Forum Commoner
Posts: 26
Joined: Sat Feb 14, 2004 5:11 pm

Post by timka »

man u guys make it sound so easy. but for a complite nOOb its very hard to even understand could any of maybe make one for me? Il'' give u credit for it on my site. or maybe we can work something out. JUST PM me if ur up for it.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

the only reason it took us a few seconds to respond is because its just text, not code.

i wish psuedo code worked in php ;)

you're going to have to learn it and use what we said as a reference if you're stuck on what to do next.

and if you have any questions, be sure to post here, we'll be more than happy to answer them, but this isnt a 5min script, so you'll have to do it yourself

good luck :)
timka
Forum Commoner
Posts: 26
Joined: Sat Feb 14, 2004 5:11 pm

Post by timka »

I know I have to learn, but first I have to start with simple stuff, but goin from nothing to making a image gallery. thats not possible so thats where I ask for help from pros. I know when u guys were starting u didn't just go on to creating big stuff u went to colleges or read books, and im just starting with PHP I don't even have a single book about it.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

like LiLpunkSkater pointed out, look over some tutorials. w3schools is really good, but i the php manual would be a lot of help....
Also the tuts at PHPFreaks.com are pretty good
timka
Forum Commoner
Posts: 26
Joined: Sat Feb 14, 2004 5:11 pm

Post by timka »

ok with a little help from a friend I created a script
index.php

Code: Select all

<table width="100%"><tr><td width="50%">  
<form action="vote.php" method="post">  
<img src="images/image1.jpg"><br>  
<input type="radio" name="image" value="image1">  
</td>  
<td width="50%">  
<img src="images/image2.jpg">  
<input type="radio" name="image" value="image2">  
</td></tr>  
<tr><td width="100%" align="center"><input type="submit" value="Vote!" name = "submit"></td></tr></table>
vote.php

Code: Select all

<?  
//connect to db with remote file 
include('dbinfo.inc.php');  
//end connect to db 
if($image='image1')&#123;  
mysql_query("INSERT INTO tablename (image) VALUES ('$image')") or die(mysql_error());  
$query = "SELECT * FROM tablename WHERE image='$image'"; 
$num = mysql_num_rows($query); 
echo " You vote for $image .  It has been voted for $num times!";  
&#125; else &#123;  
$image = 'image2';  
mysql_query("INSERT INTO tablename (image) VALUES ('$image')") or die(mysql_error());  
$query = "SELECT * FROM tablename WHERE image='$image'"; 
$num = mysql_num_rows($query); 
echo " You vote for $image .  It has been voted for $num times!"; 
&#125;  
?>
that is the original script I asked for help because it was giving me this error Table 'modifie_test.tablename' doesn't exist
the guy told me that I have to create table in phpMyAdmin so I did

in My Admin I created three tables
Votes
image
imageSrcPath
inside tabke Votes
voteID mediumint(9) No auto_increment
imageID mediumint(9) No 0
voteDate datetime No 0000-00-00 00:00:00
inside table image
imageID mediumint(9) No auto_increment
voteID mediumint(9) No 0
voteDate datetime No 0000-00-00 00:00:00
inside table imageSrcPath
imageSrcPath varchar(255) No
is this correct?
if yes why is the page blank or do I have to make any images?

I also edited the original script to this

Code: Select all

<?  
//connect to db with remote file 
include('dbinfo.inc.php');  
//end connect to db 
if($image='image1')&#123;  
mysql_query("INSERT INTO Votes (imageID) VALUES ('$_POST&#1111;imageID]')") or die(mysql_error());  
$query = "SELECT * FROM Votes WHERE imageID='$image'"; 
$num = mysql_num_rows($query); 
echo " You vote for $image .  It has been voted for $num times!";  
&#125; else &#123;  
$image = 'image2';  
mysql_query("INSERT INTO Votes (imageID) VALUES ('$_POST&#1111;imageID]')") or die(mysql_error()); 
$query = "SELECT * FROM Votes WHERE imageID='$image'"; 
$num = mysql_num_rows($query); 
echo " You vote for $image .  It has been voted for $num times!"; 
&#125;  
?>
and now the page comes up blank
u can see it at http://www.modifiersonline.com/test/

I hope now u guys can help me figure this thing out.
Post Reply