Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Created a this or that website

    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.

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by Xaqa View Post
    .....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.

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bullant View Post
    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?

  • #4
    New Coder
    Join Date
    Apr 2011
    Location
    New Delhi, India
    Posts
    27
    Thanks
    0
    Thanked 2 Times in 2 Posts
    hey xaqa

    u might be looking for something like this

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

  • #5
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Yes, something along those lines except I'm not going to pay 20$ for one. :P

  • #6
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by Xaqa View Post
    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.

  • #7
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Code:
    <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.

  • #8
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    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.

  • #9
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    I have this I forgot to add:

    (At top of page)

    Code:
    <?php
    include("config.php");
    ?>
    Then my config.php:

    Code:
    <?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?

  • #10
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by Xaqa View Post
    Would work when connecting to MySQL database?
    Did you get a connection when you ran that code?

  • #11
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    I'm not sure. But I have a new code. And it's here: http://www.technabled.com/2011/02/pu...wn-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.

  • #12
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by Xaqa View Post
    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.

  • #13
    Regular Coder
    Join Date
    May 2011
    Posts
    122
    Thanks
    23
    Thanked 0 Times in 0 Posts
    I have the general codes, just I have no idea where to place them in my HTML.

  • #14
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    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.

  • Users who have thanked bullant for this post:

    Xaqa (05-03-2011)

  • #15
    New Coder
    Join Date
    Apr 2011
    Location
    New Delhi, India
    Posts
    27
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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/


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •