SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySql and javascript

    I have the following code in a javascript file . It works, not the fanciest code but it gets the job done. However what is a royal pain, is that all the data is aleady in a table in MySql. so when I need to update the data, I have to do it in MsSql and in my java code.
    I have been told there is no way to carry data from a table into a javascript but thought I asked again. I'm sure that somewhere, somehow, someone has come up with an idea.

    I know another way would be to avoid using javascrip but the JS does exactly what I need.

    Pat

    Code:
    var noms = new Array(25) ;
    var director = new Array(25) ;
    var adresse = new Array(25) ;
    var cp = new Array(25) ;
    var ville = new Array(25) ;
    var tel = new Array(25) ;
    var fax = new Array(25) ;
    var nb_lits = new Array(25) ;
    var nb_posts = new Array(25) ;
    var doder = new Array(25) ;
    var dssi = new Array(25) ;
    	
    	noms[1] = "Ange G";
    	director[1] = "Gérard SEIzzzSEN";
    	adresse [1] = "rue Léopold Bellan";
    	cp [1] = "99999 " ;
    	ville [1] = "CHAMIGNaY" ;
    	tel[1] = "99 9 24 58 00";
    	fax[1] = "99 99 88 73 44";
    	nb_lits[1] = "98";
    	nb_posts[1] = "0";
    	doder[1] = "Nathalie Aaaaaa";
    	dssi[1] = "Nathalie Ggggggg";
    
    	noms[2] = "BBBBB";
    	director[2] = "Denis Lllllll";
    	adresse [2] = "Les Plats";
    	cp [2] = "67888 " ;
    	ville [2] = "LA ROCHE BLANCHE" ;
    	tel[2] = "77 89 79 84 46";
    	fax[2] = "78 88 79 83 86";
    	nb_lits[2] = "130";
    	nb_posts[2] = "30";
    	doder[2] = " CCCC";
    	dssi[2] = "Valérie aaaa";

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    First, the language is called JavaScript, not Java. Java is a completely different language that will only serve to confuse people if you use that name.

    You should have your server code create some JSON text with that database code. Then you can use ajax to retrieve that JSON text, parse it into a JavaScript object.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru glenngould's Avatar
    Join Date
    Nov 2005
    Posts
    661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been told there is no way to carry data from a table into a javascript
    You can get data from the database using AJAX.
    Tweep List adds an avatar menu to Twitter (open source)
    Word Stats shows your most used words on Twitter

  4. #4
    SitePoint Addict
    Join Date
    May 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't realise I used the word JAVA but you are correct.
    I'll look into json, and ajax, I have never used ajax before but maybe it is about time

    Quote Originally Posted by pmw57 View Post
    First, the language is called JavaScript, not Java. Java is a completely different language that will only serve to confuse people if you use that name.

    You should have your server code create some JSON text with that database code. Then you can use ajax to retrieve that JSON text, parse it into a JavaScript object.


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
  •