Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Okay, This should be simple for you guys.

Okay, This should be simple for you guys.

Scheduled Pinned Locked Moved Web Development
javascriptphpmysqlhelpannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stathread
    wrote on last edited by
    #1

    I have 1 php page. What I want to do is update a label on this page with a record count. So lets say the label is called "Records" and it looks like this "Records: 15" well while you are on the page not doing anything I want it to refresh this label every so often with the latest record count. Ive tried to search and read about ajax/js ect but still have not found a viable solution to my issue. Remember I am using php/mysql. Thanks in advance. Josh

    T D 2 Replies Last reply
    0
    • S Stathread

      I have 1 php page. What I want to do is update a label on this page with a record count. So lets say the label is called "Records" and it looks like this "Records: 15" well while you are on the page not doing anything I want it to refresh this label every so often with the latest record count. Ive tried to search and read about ajax/js ect but still have not found a viable solution to my issue. Remember I am using php/mysql. Thanks in advance. Josh

      T Offline
      T Offline
      T M Gray
      wrote on last edited by
      #2

      You should be able to do that with AJAX pretty easily, but since you don't say what you have tried and the specific problem you ran into I'll suggest a different route. META refresh[^]

      1 Reply Last reply
      0
      • S Stathread

        I have 1 php page. What I want to do is update a label on this page with a record count. So lets say the label is called "Records" and it looks like this "Records: 15" well while you are on the page not doing anything I want it to refresh this label every so often with the latest record count. Ive tried to search and read about ajax/js ect but still have not found a viable solution to my issue. Remember I am using php/mysql. Thanks in advance. Josh

        D Offline
        D Offline
        Dr Walt Fair PE
        wrote on last edited by
        #3

        If you don't want the whole page to refresh when you update, then you probably need to use AJAX with a timer event to call the PHP code that returns the updated record count. On the PHP side it could be as simple as doing a select query and returning a count. On the Javascript side you'll need to provide a call to your PHP using AJAX and if all you want back is a record count, you can get that with the text property rather than doing a whole XML transfer. Without writing the whole thing, your PHP could be as simple as:

        // Set up MySql connection
        $sql= "SELECT COUNT(*) FROM mytable WHERE Whatever = 'What Im looking for'";
        $result = mysql_query($sql) or die("Sorry, you screwed up!");
        echo mysql_num_rows($result);

        Here's an example of doing the stuff based on a timer event in Javascript[^]. You'd put your function to do the update call as the argument to the timer. To handle the AJAX, take a look at this PHP AJAX tutorial[^]. You put your own Javascript code to handle the return and update your label as required.

        CQ de W5ALT

        Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups