How do I update a json file with mysql data using php
Posted: Fri Jan 02, 2015 4:02 pm
Hello friends,
I am knowledgeable in PHP but not in JSON. But I have a JSON script that I want some of the data in it to be dynamic from mysql database. I have products page where all products are listed, on clicking any product it opens product detail page where this JSON script coordinates. Below is d JSON file
[text]
{
"AllCategorys": {
"Category": [
{
"id": "7",
"title": "Women",
"isDefault": "7",
"subCategory": [
{
"products": [
{
"isDefault": "25",
"id": "25",
"title": "Men Tshirt",
"thumbnail": "imgs/cards/61946.Thumb.jpg",
"rawprice": "0",
"colors": {
"color": [
{
"views": {
"view": [
{
"id": "1",
"isDefault": "1",
"title": "Front",
"viewname": "Front",
"imagewidth": "322",
"imageheight": "422",
"subitemid": " 0 ",
"viewthumbnail": "imgs/cards/61946-Bg.png",
"container": "true",
"x": "0",
"y": "0",
"width": "381",
"height": "479",
"printwidth": "10",
"printheight": "15"
},{
"id": "2",
"isDefault": "2",
"title": "FrontInside",
"viewname": "Front Inside",
"imagewidth": "351",
"imageheight": "439",
"subitemid": " 0 ",
"viewthumbnail": "imgs/cards/FrontInside.png",
"container": "true",
"x": "0",
"y": "0",
"width": "350",
"height": "500",
"printwidth": "100",
"printheight": "150"
},{
"id": "3",
"isDefault": "3",
"title": "BackInside",
"viewname": "Back Inside",
"imagewidth": "351",
"imageheight": "439",
"subitemid": " 0 ",
"viewthumbnail": "imgs/cards/BackInside.png",
"container": "true",
"x": "0",
"y": "0",
"width": "350",
"height": "500",
"printwidth": "100",
"printheight": "150"
}, {
"id": "4",
"title": "Back",
"viewname": "Back",
"imagewidth": "322",
"imageheight": "422",
"subitemid": " 0 ",
"viewthumbnail": "imgs/cards/938324.Bg.png",
"container": "true",
"x": "0",
"y": "0",
"width": "381",
"height": "479",
"printwidth": "10",
"printheight": "15"
}
],
"Sizes": {
"size": [
{
"id": "22",
"isDefault": "22",
"title": "A4",
"sizeprice": "2000"
}, {
"id": "23",
"title": "A5",
"sizeprice": "1500"
}, {
"id": "21",
"title": "A6",
"sizeprice": "1000"
}
]
}
}
}
]
}
}
]
}
]
}
]
}
}
[/text]
My problems are how to make the below parts dynamic from mysql database (probably using PHP)
[text]
"Category": [
{
"id": "7",
"title": "Women",
"isDefault": "7",
[/text]
[text]
"products": [
{
"isDefault": "25",
"id": "25",
"title": "Men Tshirt",
"thumbnail": "imgs/cards/61946.Thumb.jpg",
"rawprice": "0",
[/text]
[text]
"Sizes": {
"size": [
{
"id": "22",
"isDefault": "22",
"title": "A4",
"sizeprice": "2000"
}, {
"id": "23",
"title": "A5",
"sizeprice": "1500"
}, {
"id": "21",
"title": "A6",
"sizeprice": "1000"
}
]
}
[/text]
Thanks
I am knowledgeable in PHP but not in JSON. But I have a JSON script that I want some of the data in it to be dynamic from mysql database. I have products page where all products are listed, on clicking any product it opens product detail page where this JSON script coordinates. Below is d JSON file
[text]
{
"AllCategorys": {
"Category": [
{
"id": "7",
"title": "Women",
"isDefault": "7",
"subCategory": [
{
"products": [
{
"isDefault": "25",
"id": "25",
"title": "Men Tshirt",
"thumbnail": "imgs/cards/61946.Thumb.jpg",
"rawprice": "0",
"colors": {
"color": [
{
"views": {
"view": [
{
"id": "1",
"isDefault": "1",
"title": "Front",
"viewname": "Front",
"imagewidth": "322",
"imageheight": "422",
"subitemid": " 0 ",
"viewthumbnail": "imgs/cards/61946-Bg.png",
"container": "true",
"x": "0",
"y": "0",
"width": "381",
"height": "479",
"printwidth": "10",
"printheight": "15"
},{
"id": "2",
"isDefault": "2",
"title": "FrontInside",
"viewname": "Front Inside",
"imagewidth": "351",
"imageheight": "439",
"subitemid": " 0 ",
"viewthumbnail": "imgs/cards/FrontInside.png",
"container": "true",
"x": "0",
"y": "0",
"width": "350",
"height": "500",
"printwidth": "100",
"printheight": "150"
},{
"id": "3",
"isDefault": "3",
"title": "BackInside",
"viewname": "Back Inside",
"imagewidth": "351",
"imageheight": "439",
"subitemid": " 0 ",
"viewthumbnail": "imgs/cards/BackInside.png",
"container": "true",
"x": "0",
"y": "0",
"width": "350",
"height": "500",
"printwidth": "100",
"printheight": "150"
}, {
"id": "4",
"title": "Back",
"viewname": "Back",
"imagewidth": "322",
"imageheight": "422",
"subitemid": " 0 ",
"viewthumbnail": "imgs/cards/938324.Bg.png",
"container": "true",
"x": "0",
"y": "0",
"width": "381",
"height": "479",
"printwidth": "10",
"printheight": "15"
}
],
"Sizes": {
"size": [
{
"id": "22",
"isDefault": "22",
"title": "A4",
"sizeprice": "2000"
}, {
"id": "23",
"title": "A5",
"sizeprice": "1500"
}, {
"id": "21",
"title": "A6",
"sizeprice": "1000"
}
]
}
}
}
]
}
}
]
}
]
}
]
}
}
[/text]
My problems are how to make the below parts dynamic from mysql database (probably using PHP)
[text]
"Category": [
{
"id": "7",
"title": "Women",
"isDefault": "7",
[/text]
[text]
"products": [
{
"isDefault": "25",
"id": "25",
"title": "Men Tshirt",
"thumbnail": "imgs/cards/61946.Thumb.jpg",
"rawprice": "0",
[/text]
[text]
"Sizes": {
"size": [
{
"id": "22",
"isDefault": "22",
"title": "A4",
"sizeprice": "2000"
}, {
"id": "23",
"title": "A5",
"sizeprice": "1500"
}, {
"id": "21",
"title": "A6",
"sizeprice": "1000"
}
]
}
[/text]
Thanks