www.webdeveloper.com
Results 1 to 2 of 2

Thread: Import PHP in JAVASCRIPT and SQL

Threaded View

  1. #1
    Join Date
    Jan 2014
    Posts
    1

    Question Import PHP in JAVASCRIPT and SQL

    Hey guys its my first post ...
    So i have a suggestion box for countries and i need to get the countries from SQL database..
    It only shows the last one ...
    PHP Code:
    <?php
     mysql_connect
    ("127.0.0.1""root""---") or die(mysql_error()); 
     
    mysql_select_db("xxx") or die(mysql_error()); 
     
    $data mysql_query("SELECT * FROM countries"
     or die(
    mysql_error());  
     while(
    $info mysql_fetch_array$dataMYSQL_ASSOC)) 
     { 

    ?>

           $(document).ready(function() {
                var jsonData = [];
                var cities = '<?php echo $info['country'].","; }   ?>'.split(',');
                for(var i=0;i<cities.length;i++) jsonData.push({id:i,name:cities[i],status:i%2?'':'Planned for visit',coolness:Math.floor(Math.random() * 10) + 1});
                var ms1 = $('#ms1').magicSuggest({
                    data: jsonData,
                    sortOrder: 'name',
                    value: [0,1,2,3,4,5,6],
                    groupBy: 'status',
                    maxDropHeight: 2000,
                    name: 'ms1'
                });

            });
    If you could help i would be greatful, THanks.
    Last edited by NogDog; 02-07-2014 at 08:08 PM. Reason: replaced <code> tags with [php] tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles