www.webdeveloper.com
Results 1 to 2 of 2

Thread: Import PHP in JAVASCRIPT and SQL

  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 07:08 PM. Reason: replaced <code> tags with [php] tags

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,344
    You have posted a JQuery issue, please ask in the JQuery forums (frameworks)



    ...Or maybe a combination of PHP and JQuery...
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

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