Results 1 to 3 of 3

Thread: AJAX + Javascript + MySQL Advice

  1. #1
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default AJAX + Javascript + MySQL Advice

    I've been searching the web for a basic tutorial that i can follow that will show me how to have a link on my website that says something to the effect of,

    "Like(0)" and "Dislike(0)"

    When the user clicks either link it increments by 1. Saving the new number to a database and updating the content on the main page without reloading the entire page, Ajax/javascript?

    Any idea towards a tutorial would be great help!

    Thanks.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The good news is that is about as simple as Ajax gets-- click it, send the request, and have a basic php script waiting on the other end to update the mysql.
    The bad news is that there isn't too much specific advice we can give for this, because it is, again, just the basic version of Ajax.
    You should be able to use any tutorial that explains Ajax, then connect that with a basic php page that uses mysql.
    For the second part, this has some good info. The site is a bit cluttered at the moment (with newer, not so helpful posts), but if you look back to the oldest posts they're good introductions to how to use php and mysql.
    http://php-mysql-tutorial.com

    Toward specifics, all you need to do is send two values: the item/page/whatever you want to modify, and whether you are doing dislike or like. Then once that request is received by php, update the number in the database by adding one-- you won't need to send that number with Ajax.

    Depending on how the system works, you will need to figure out security issues. You don't want a direct link to the page to work easily, so you may actually want to track users (maybe IP addresses, which are less reliable), and only allow one vote-- that means you'll need to actually track this in the database, which gets a lot more complex, but is based on the same basic principles-- get the simple version working then work your way up to the complex one.


    Edit: and if you need more info, this is very similar to a voting system, so just look for any tutorials using ajax and voting.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    Yeah i have a fairly decent understanding of the working of php and mysql. I guess i just get lost in where the php and mysql connections come into play, where the files are called etc.

    I'll take a look at it after the holiday season and if i have any questions, ill post here.

    Thanks, and happy holidays!

Bookmarks

Posting Permissions

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