Jump to content

Search the Community

Showing results for tags 'json_encode'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 3 results

  1. I have an autocomplete() function connected to a MYSQL database. The jquery is completely run of the mill: $(function() { $(".choose_venue").autocomplete({ source: "list_venues.php", minLength: 1 }); }); ...and if I manually add a query such as "list_venues.php?term=Ku" onto the URL of list_venues.php, then that page gives a appropriate response (such as the following): [{"name":"Fonderie Kugler"},{"name":"Kulturhaus Helferei"},{"name":"Kunstraum Walcheturm"}]So, a simple `input` such as the following *should* be working: <input type="text" style="width:270px;" class="choose_venue"/> However, the output I get is a window containing no text, but just a number of faint lines. I first thought that this might be something in my CSS, but the problem persists even when ALL css modifications have been removed. My next thought was that it might be a browser issue (I use Safari), but Chrome behaves exactly the same way. The only other idea I had was that the jquery files I was calling were out of date or that there was some other problem, but I tried multiple links and I always get the same result. As of my most recent attempts I am linking to the following files: <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> It appears that the number of these grey lines corresponds to the number of text values that should be returned. But beyond that, I have no idea what is causing this.
  2. ibrahimjan

    Create Json data

    Please have a look at my json data to see what I want to do: [ { "weID": "-126555895", "size_h": "700", "size_w": "494", "images": [ { "imgID": "1535689403", "imgName": "1321865407" } ], "text": [ { "txtID": "-1892792786", "txtText": "4.99" }, { "txtID": "1583276033", "txtText": "$" } ] }, // i cant seem to loop through my data to get more results looking like this:{ "weID": "3444555435", "size_h": "500", "size_w": "294", "images": [ { "imgID": "-454646555", "imgName": "77774433" }, { "imgID": "1535689403", "imgName": "1321865407" } ], "text": [ { "txtID": "15834443333", "txtText": "more text" } ] }] //my PHP code: $back = mysql_query("SELECT weID, size_h, size_w FROM wb WHERE weID=-126555895");$images = mysql_query("SELECT imgID, imgName FROM wi WHERE weID=-126555895");$text= mysql_query("SELECT txtID, txtText FROM wt WHERE weID=-126555895"); //all my above SQL statements have weID in common, how can I link them together, to show all my results rather then one "-126555895"?? $model = array(); while($e = mysql_fetch_assoc($back)){ $model['weID'] = $e['weID']; $model['size_h'] = $e['size_h']; $model['size_w'] = $e['size_w']; while($h = mysql_fetch_assoc($images)) { $model['images'][] = array( 'imgID' => $h['imgID'], 'imgName' => $h['imgName'] ); while($f = mysql_fetch_assoc($text)){ $model['text'][] = array( 'txtID' => $f['txtID'], 'txtText' => $f['txtText'] );}; };}; echo json_encode ($model); mysql_close($con); I need it to loop through so it can display all the records in
  3. Hi,Apologies if I'm doing something very obviously stupid here, I'm fairly new to this sort of thing. What I'm basically trying to do is crop a two dimensional array of coordinates to the same length as another array called from an sql database using php and then made useable in javascript via json_encode. The good news is that I've managed to accomplish this. The code below actually does this twice with the database information called in different orders so that I have two two-dimensional javascript arrays, each with an x and y coodinate tagged onto the end of each row. (For anyone who's interested in the whys and wherefores, the database contains information abpout different image galleries (title, description, thumbnail etc). I'm going to be using these two arrays along with jquery animate to allow visitors to the site to change the order in which thumbnails are displayed based on date gallery updated or gallery size). This all sort of works fine. There are a couple of functions, 'prune' which is the parent function (I think I'm using the terminology correctly) and two similar but separate 'populateArray' functions (1 and 2). The trouble is that the two inner functions don't seem to want to return a value. I can access the two arrays from within the populateArray functions but as soon as I try to return the values (as 'galDate' and 'galSize') I get nothing. Code is laid out below. Like I say, apologies if I'm making a really basic mistake here but I'm completely stumped and could do with a nod in the right direction. Thanks in advance.Stef <script>var sqlData1 = (<?php print json_encode($sqlData1);?>);var sqlData2 = (<?php print json_encode($sqlData2);?>); var coordinates = [['100px','100px'],['100px','200px'],['100px','300px'],['200px','100px'],['200px','200px'],['200px','300px'], ['300px','100px'],['300px','200px'],['300px','300px'],['400px','100px'],['400px','200px'],['400px','300px'],['500px','100px'],['500px','200px'],['500px','300px']]; //Function to make arrays the same length function pruneArrays(sqlData1,sqlData2, coordinates){ for(i=(coordinates.length-sqlData1.length); i>0; i--){ coordinates.pop(coordinates); } populateArray1(sqlData1, coordinates); populateArray2(sqlData2, coordinates); return();} //Function to create date ordered array with coordinatesfunction populateArray1 (sqlData1, coordinates){ for(i=0; i<sqlData1.length; i++){ for(j=0; j<(sqlData1.length-1); j++){ sqlData1.push(coordinates[j]); } } var galDate = sqlData1; //document.write(galDate); - if this line is active 'galDate' displays no problem //document.write ("<br /><br />"); return (galDate);} //Function to create size ordered array with coordinatesfunction populateArray2 (sqlData2, coordinates){ for(i=0; i<sqlData2.length; i++){ for(j=0; j<(sqlData2.length-1); j++){ sqlData2.push(coordinates[j]); } } var galSize = sqlData2; //document.write(galSize); - if this line is active 'galSize' displays no problem return (galSize);} document.write(pruneArrays(sqlData1, sqlData2, coordinates));// The line above however, doesn't return anything.</script>
×
×
  • Create New...