Search Posts

Category: json

Cannot insert multiple records at a time with php and angular2

I’m trying to insert multiple records from selected checkboxes to mysql db with php. What is happening is after i post and go to check the db, i find all the records inserted in one line instead of each making a unique insertion. Below is the data is post in an array [“A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”,”A”,”B”,”C”,”C”,”B”,”A”,”D”,”B”,”D”,”A”,”A”,”A”,”B”,”A”,”B”,”B”,”B”,”C”,”B”,”B”,”A”,”A”,”A”,”C”,”B”,”B”,”D”,”C”,”C”,”C”,”B”,”D”,”D”,”D”,”D”,”D”,”C”,”D”,”C”,”A”] PHP <?php require_once(‘../Connections/catchapp.php’); ?> <?php $data= json_decode(file_get_contents(“php://input”)); $uanswer= mysql_real_escape_string($data->useranswer); foreach ((array) $uanswer as $item) { mysql_select_db($database_catchapp, $catchapp); $insertSQL = (“INSERT INTO user_answers […]

filtering in an ng-repeat from JSON response

I’ve got a question about filtering within a ng-repeat. But this isn’t a simple question since I’m not really having a problem that needs a solution. In this case, i’m looking for the best possible answer that doesn’t require a lot of code but still does the trick as to how I want it to. It will become more clear in my description. a short introduction: So I’m currently working on a shopping application. The […]

create new json from existing json using AngularJS or Javascript

Category JSON I am getting this JSON by accessing API and soring it in $scope.categoryList [ { “id”: 1, “name”: “Men” }, { “id”: 2, “name”: “Women” }, { “id”: 3, “name”: “Kids” } ] SubCategory JSON I am getting this JSON by accessing API and soring it in $scope.subCategoryList [ { “id”: 1, “category_id”: 1, “name”: “Footwear” }, { “id”: 2, “category_id”: 2, “name”: “Footwear” }, { “id”: 3, “category_id”: 1, “name”: “Cloths” } […]

Link json data into a JS/Jquery variable [duplicate]

This question already has an answer here: Why does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not? 31 answers I am trying to link data from a json file to a js variable. What is working : I can manually write and use data like it : This is working very well … var bars = [ { lat: 48.11300540000001, lng: -1.6825228000000152, name: ‘Le Kenland’, […]

How to load different part of data from JSON file for each page using AngularJS?

I’m trying to create a shopping website using angularJs. My website has several html pages like women.html, men.html,… I has 1 JSON file for the whole website. I want each website has different products, I did it but it only works on the main page (the page which showing all the products). When I click on a specific product, it doesn’t show anything thing. For more clearly, here is my code: JSON file: { “Men”: […]

Select specific values from json_decode in php

I’ve stumbled on a problem that i think is a bit strange since i’ve followed other examples to the exact code but i still didn’t get the same result. Short summary I’m developing a shopping application and i’m using a session for the cart. Since i want to have the possibility to remove items from the cart i am using some levels inside the JSON object of the session. Cart summary The cart is created […]

Binding JSON data to a html angularjs data table

Im a newbie to angular, currently i have created a datatable using html and angular, can you guys help me on how to bind a JSON data into this table… my scripts are as follows html script <div class=”container-fluid”> <div class=”row”> <div class=”col-xs-12 col-sm-7 col-md-7 col-lg-4″> <page-title [title]=pageTitle></page-title> </div> </div> <div class=”row”> <div class=”col-12″> <data-table [dataTable]=”dataTable” ></data-table> </div> </div> ts script export class UploadsComponent implements OnInit { pageTitle = ‘<i class=”fa fa-table fa-fw”></i>Uploads’; dataTable: DataTable; […]

Display JSON data with Ionic 2/AngluarJS?

I’m fetching API data using AngularJS/Ionic 2. I’ve followed this guide and get it to properly log the data when I go to home.html. But when I try to actually display the data in home.html I can’t get it to work. data-provider.ts: getRemoteData(){ this.http.get(‘’).map(res => res.json()).subscribe(data => { console.log(data); }); } home-ts: ionViewDidLoad(){ this.dataService.getRemoteData(); } This correctly logs JSON data: [ { “id”: “a”, “name”: “ExampleA”, “price”: “10” }, { “id”: “b”, “name”: “ExampleB”, “price”: […]

AngularJS binding chokes on closing round bracket in JSON

I’m getting this error: Error: [$parse:lexerr] Lexer Error: Unterminated quote … …. when angular tries to bind some JSON to my view. This is because part of my json has a closing round bracket like this: [{“title”:”(MyString)”}] This is correctly formed in the JSON, however at some point when angular tries to bind the JSON, I get the error. It’s like angular is interpreting the closing round bracket as JavaScript or something, so it fails […]

Next Page »