Results 1 to 2 of 2

Thread: Javascript + PHP = Count Rows

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Javascript + PHP = Count Rows

    Hi I am currently working on a project, where I need to count in an ajax/javascript way to show when a new row is added, without the user having to refresh the page.

    As we use MySQL, PHP5 and we already use some javascript, I am wondering how I would get it to show a counter like http://www.twitpocalypse.com/
    But instead of all being Javascript, it would count how many rows are in the DB.

    The table that we want to get the data out of is named entry
    Thanks
    The web in one word.

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

    Default

    Ajax is just a method to get data from PHP. Simply put, you need to just design a script in php that will return the number of rows, request that with Ajax, and display that value in Javascript. It shouldn't be too difficult if you've already got most of it setup, but you will need to worry about security issues (because Ajax requests are made the same way anyone could request that PHP script, so be sure it doesn't reveal anything you don't want to be public knowledge).
    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

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
  •