SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot maileen's Avatar
    Join Date
    Apr 2006
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How javascript could read PHP database query result

    Hi,

    basically i have a php file with several parameter received in GET or POST.
    this PHP page execute a db query and should return a specific amount of records and columns.

    however i do not want to display those records like that...
    i have a web page with javascript and the javascript should read those records/query results and display them.

    how can javascript read those result ?
    i do not want php file to create a temporary file on server, i would like to read those data on fly.
    so how can i do that ?

    thx.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    This is where you use AJAX

    Bulletproof Ajax has some good example code from their book.
    See the Chapter 5 Contact Us piece.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Zealot maileen's Avatar
    Join Date
    Apr 2006
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My main issue is how will look like date from responsetext when i php script should return several records from database (several columns and lines) ?
    how to make a difference between columns name ?

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don't really need to manipulate the data in javascript, then just have php echo out the html in the proper markup/order/format. Then javascript injects this html into the DOM(for example, myDiv.innerHTML = myAjaxResponseText;).

    If you need javascript to manipulate it though, you make the php script return the results in some type of structured format which javascript can parse/understand. For example, json or xml. php can easily produce these formats for you.


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
  •