Need help on javascript that counts how many rows are present in mysql...

Discussion in 'JavaScript' started by jehzlau, Nov 16, 2007.

  1. #1
    Need help on javascript that counts how many rows are present in mysql that I can embed in an HTML file... I just don't know how to do it... Can anyone help me with this noob stuff :(

    I just want to display how many rows are present in a specific table in an HTML file using a simple javascript :(

    please help a javascript noob :( T__T
     
    jehzlau, Nov 16, 2007 IP
  2. udkl_12_98

    udkl_12_98 Banned

    Messages:
    307
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You cant do that as JavaScript is at client side and MySQL is on the server side.

    Though you cant do that with purely JavaScript you can however communicate with a server through an xmlhttprequest object, its referred to as AJAX (or activex, java, actionscript), though you will require PHP .
     
    udkl_12_98, Nov 17, 2007 IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    Not possible.

    Best Javascript/HTML can do is ask the server to find out for it.
     
    joebert, Nov 19, 2007 IP
  4. aRo`

    aRo` Peon

    Messages:
    141
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you could use javascript to fetch the content of a php file(you should echo the # here), and capture that value in your javascript ajax call.

    you can see how to use a simple ajax call here
     
    aRo`, Nov 19, 2007 IP
  5. jehzlau

    jehzlau Active Member

    Messages:
    301
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #5
    but how? I don't know to much about javascript :(
     
    jehzlau, Nov 25, 2007 IP
  6. udkl_12_98

    udkl_12_98 Banned

    Messages:
    307
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You have to learn Ajax for that ... It is pretty simple ,even for a noob...Check out tutorials on the net for ajax. Also you will requires knowledge of one server side language like php,perl...etc etc
     
    udkl_12_98, Nov 26, 2007 IP
  7. jehzlau

    jehzlau Active Member

    Messages:
    301
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #7
    hehehe.. i finally got it :) thanks anyway for the help guys :)

    i just used the mysql_num_rows function to count the rows.. it's all that i'm looking for.. heehee :)
     
    jehzlau, Nov 30, 2007 IP