- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 JSON 数据解析到我的数据库中。
一切都很顺利,直到嵌套数组为止。
我试图将其保存为 MYSQL(phpMyAdmin) 中的数组,但没有结果。
这是我的 Json 文件:
{"_links":
{
"first":
{
"href":"https://www.widgety.co.uk/api/ships.json?app_id=e701363eb6259342c9ce&limit=1&page=1&token=087c57b15f6e52098e2ad181db0e11919"
}
},
"count":1,"total":788,
"ships":[
{
"title":"AIDAperla",
"id":1052,
"profile_image_href":"https://widgety-assets.s3.amazonaws.com/2016/06/06/22/33/28/223/AIDA_Cruises_Logo_1.jpg",
"cover_image_href":"https://widgety-assets.s3.amazonaws.com/2017/03/22/00/00/22/739/AIDAperla.jpg",
"href":"https://www.widgety.co.uk/api/ships/aidaperla.json",
"html_href":"https://www.widgety.co.uk/ships/aidaperla",
"ship_class":"",
"size":"large",
"style":"resort",
"celebrity_ties":"<p>Tim Malzer- German Celebrity Chef</p>",
"gratuities":"<p>All gratuities are included in the Cruise fare.</p>",
"ship_facts":{
"launch_year":"2017",
"refit_year":"",
"language":"de+en",
"gross_tonnage":124500,
"length":300.0,
"width":37.6,
"currency":"EUR",
"speed":22,"capacity":3300,
"crew_count":900,
"deck_count":16,
"cabin_count":1643,
"large_cabin_count":null,
"wheelchair_cabin_count":null
},
"dining":{
"intro":"<p>At 13 bars the bar team will spoil you with cocktails, wines, beer and champagne.</p><p>In Café Mare (Deck 7) they serve coffee, tea and chocolate specialties, in the wine cellar (Deck 8) wines from around the world and in the Bar 5th Element (deck 14) can families relaxed end the day. In the exclusive Spray Bar (deck 6) , you can go directly on the bow, where you can feel the spray, the spray, on your face and enjoy your champagne. In the Nightfly (Deck 6) you can enjoy exclusive entertainment and in the discotheque D6 (Deck 6) dance night owls dance until dawn.</p><p>All opening hours and special offers can be found in the on-board newspaper. </p><p></p><ul><li>Scharfe Ecke (Sharp Corner, complimentary fastfood dining venue)<br></li><li>Rossini (specialty, dinner-only restaurant at surcharge, reservations required; offers waiter service and 6-course a-la-carte menu)<br></li><li>Market Restaurant (complimentary main dining room; self-service buffet restaurant with a variety of food stations and a small terrace)<br></li><li>Bella Donna (Italian cuisine restaurant, complimentary, buffet-style dining, open 24 hours)<br></li><li>Ristorante Casa Nova (Mediterranean cuisine restaurant at surcharge)<br></li><li>Brasserie French Kiss (French cuisine restaurant, reservations-only, at surcharge)<br></li><li>Weite Welt Restaurant (Wide World complimentary buffet-style restaurant)<br></li><li>Buffalo Steakhouse (American fare restaurant with a la carte menu; reservations required; at surcharge)<br></li><li>Sushi Bar (Japanese restaurant at surcharge, reservations are required)<br></li><li>Fuego Restaurant (new family restaurant, complimentary, with a kids buffet)<br></li><li>East Restaurant (Asian cuisine, buffet-style complimentary restaurant).<br></li></ul><p></p>",
"video":""
},
"enrichment":{
"intro":"<p>More information coming soon.</p>",
"video":""
},
"entertainment":{
"intro":"<p>Your chocolate, your topping, your ice cream! In the first MAGNUM Pleasure Store on the sea, you can create your personal favourite ice cream - or try every day a different combination.</p><p>An exclusive stay, guests enjoy the spray bar by Möet & Chandon : The luxurious champagne bar with an outdoor area at the bow just above the waves is certainly the new gathering place. The famous Sundowner served in the Lanai Bar at the rear with a particularly romantic view of the sunset.</p><p>Other day: 14 cafes and bars as well as the AIDA Lounge for relaxed meetings with friends or celebrations</p><p></p><ul><li>Live music as a stylish accompaniment in selected bars<br></li><li>A touch of Casino Royale in the Casino Bar<br></li><li>Thirst quencher for adventurers in . 5 Element directly on the Activity deck<br></li></ul><p></p>",
"video":""
},
"health_and_fitness":{
"intro":"<p>On board you'll find a range of health and fitness facilities including a state-of-the-art fitness centre, a spa, jogging track, sports area, pools, jacuzzis and a waterpark.</p>",
"video":""
},
"kids_and_teens":{
"intro":"<p>There are a range of activities for kids & teens onboard AIDAperla.</p>",
"video":""
},
"useful_to_know":{
"video":""
},
"operator":{
"name":"AIDA Cruises",
"profile_image_href":"https://widgety-assets.s3.amazonaws.com/2016/06/06/22/33/28/223/AIDA_Cruises_Logo_1.jpg",
"cover_image_href":"https://widgety-assets.s3.amazonaws.com/2016/06/07/16/16/35/361/AIDAblu.jpg"},
"accomodation_types":[
{
"name":"Suite",
"description":"<p>Suite with separate sleeping area, 2 bathrooms and a walk-in closet. All cabins are air-conditioned , carpeted and have shower / WC, satellite TV, radio, safe, second pillow top and direct dial telephone. The 220 V connection in the bathroom is intended for the use of a razor. A hairdryer is in the desk drawer. </p><p></p><ul><li>Access to the AIDA Lounge and Patio deck<br></li><li>Concierge Service<br></li><li>Fresh fruit, chocolates and champagne to welcome<br></li><li>3-course menu on the welcome evening in the à la carte restaurant<br></li><li>Breakfast is served in the à la carte restaurant, in the AIDA lounge or on the cabin <br></li><li>Free use of the organic spa on the day of departure<br></li><li>Bathrobes and slippers for adults and children<br></li><li>Amenities such as bath tub and body emulsion in the bathroom<br></li><li>Turn Down Service<br></li><li>Luggage scale, chair, coat-rack and umbrella as comfort extras<br></li><li>Your favourite pillow from our pillow menu for heavenly sleep comfort<br></li></ul><p></p>",
"stats":"<p></p><ul><li>419 - 1237 sq. ft.<br></li><li>Private sun deck: 118 - 775 sq. ft.<br></li><li>Sleeps 4<br></li></ul><p></p>"
}, {
"name":"Veranda Comfort Cabin",
"description":"<p>All cabins are air-conditioned , carpeted and have shower / WC, satellite TV, radio, safe, second pillow top and direct dial telephone. The 220 V connection in the bathroom is intended for the use of a razor. A hairdryer is in the desk drawer. </p>",
"stats":"<p></p><ul><li>258 - 398 sq. ft.<br></li><li>Veranda: 43 - 172 sq. ft.<br></li><li>Sleeps 3 - 4 depending on category<br></li></ul><p></p>"
}, {
"name":"Veranda Cabin",
"description":"<p>All cabins are air-conditioned , carpeted and have shower / WC, satellite TV, radio, safe, second pillow top and direct dial telephone. The 220 V connection in the bathroom is intended for the use of a razor. A hairdryer is in the desk drawer. </p>",
"stats":"<p></p><ul><li>226 - 290 sq. ft.<br></li><li>Veranda: 43 - 139 sq. ft.<br></li><li>Sleeps 2 - 4 depending on category<br></li></ul><p></p>"
}, {
"name":"Panorama Cabin","description":"<p>Exposed position on the patio deck at the bow of deck 16.</p><p>All cabins are air-conditioned , carpeted and have shower / WC, satellite TV, radio, safe, second pillow top and direct dial telephone. The 220 V connection in the bathroom is intended for the use of a razor. A hairdryer is in the desk drawer. <br></p>",
"stats":"<p></p><ul><li>258 - 290 sq. ft.<br></li><li>Veranda: 75 sq. ft.<br></li><li>Sleeps 2 - 3 <br></li></ul><p></p>"
}, {
"name":"Lanai Cabin",
"description":"<p>Includes winter garden and porch.</p><p>Mostly with 2 bathrooms.</p><p>All cabins are air-conditioned , carpeted and have shower / WC, satellite TV, radio, safe, second pillow top and direct dial telephone. The 220 V connection in the bathroom is intended for the use of a razor. A hairdryer is in the desk drawer. <br></p>",
"stats":"<p></p><ul><li>322 - 365 sq. ft.<br></li><li>Winter garden: 64 sq. ft.<br></li><li>Veranda: 64 sq. ft.<br></li><li>Sleeps 4<br></li></ul><p></p>"
}, {"name":"Sea View Cabin","description":"<p>All cabins are air-conditioned , carpeted and have shower / WC, satellite TV, radio, safe, second pillow top and direct dial telephone. The 220 V connection in the bathroom is intended for the use of a razor. A hairdryer is in the desk drawer. <br></p>",
"stats":"<p></p><ul><li>236 - 247 sq. ft.<br></li><li>Sleeps 3 - 4 depending on category.<br></li></ul><p></p>"
}, {
"name":"Inside Cabin","description":"<p>All cabins are air-conditioned , carpeted and have shower / WC, satellite TV, radio, safe, second pillow top and direct dial telephone. The 220 V connection in the bathroom is intended for the use of a razor. A hairdryer is in the desk drawer. </p>",
"stats":"<p></p><ul><li>172 sq. ft.<br></li><li>Sleeps 2 - 4<br></li><li>Partly separated beds<br></li></ul><p></p>"
}
],
"deckplans":[
{
"name":"Deck 18",
"description":"<ul><li>1. FKK Area<br></li><li>2. Start Racer<br></li></ul>"
}, {
"name":"Deck 17",
"description":"<p></p><ul><li>3. Sun Deck<br></li></ul><p></p>"
}, {
"name":"Deck 16",
"description":"<ul><li>4. Patio Deck<br></li><li>5. Patio Bar<br></li><li>6. Beach Club<br></li><li>7. Sports Deck/Ice Rink in Winter<br></li><li>8. Climing Wall<br></li><li>Suites</li><li>Cabins</li></ul>"
}, {
"name":"Deck 15",
"description":"<ul><li>3. Sun Deck<br></li><li>6. Beach Club<br></li><li>9. TV Studio<br></li><li>10. AIDA Bar<br></li><li>11. Pool Bar<br></li><li>12. Minigolf<br></li><li>13. Teens Lounge Wave Club<br></li><li>14. Ziel Racer<br></li><li>15. Four Elements Water Park<br></li><li>16. Jogging Track<br></li><li>17. Skywalk<br></li><li>Suites</li><li>Cabins</li></ul>"
}, {
"name":"Deck 14",
"description":"<ul><li>15. Four Elements Water Park<br></li><li>18. Mini Club<br></li><li>19. Fuego Restaurant<br></li><li>20. Kids Club<br></li><li>21. 5. Element<br></li><li>Cabins</li></ul>"
}, {
"name":"Deck 12",
"description":"<p></p><ul><li>Suites<br></li><li>Cabins<br></li></ul><p></p>"
}, {
"name":"Deck 11",
"description":"<p></p><ul><li>Suites<br></li><li>Cabins<br></li></ul><p></p>"
}, {
"name":"Deck 10",
"description":"<p></p><ul><li>Suites<br></li><li>Cabins<br></li></ul><p></p>"
}, {
"name":"Deck 9",
"description":"<p></p><ul><li>Suites<br></li><li>Cabins<br></li></ul><p></p>"
}, {
"name":"Deck 8",
"description":"<ul><li>3. Outside Deck<br></li><li>3. Smoking Area<br></li><li>22. Organic Spa</li><li>23. AIDA Lounge<br></li><li>24. Sunset Bar<br></li><li>25. Excursion Counter<br></li><li>26. Theatre<br></li><li>27. Sushi Bar<br></li><li>28. Library<br></li><li>29. Rossini Restaurant<br></li><li>30. Buffalo Steak House<br></li><li>31. Lanai Deck with Infinity Pools<br></li></ul>"
}, {
"name":"Deck 7",
"description":"<ul><li>25. Excursion Counter<br></li><li>26. Theatre</li><li>31. Lanai Deck</li><li>32. Spray Bar by Moet & Chandon</li><li>33. Body & Soul Sport</li><li>34. Zen Lounge</li><li>35. Sport Shop with Biking, Golf and Dive Counter</li><li>36. Nail Spa</li><li>37. Perfume Shop</li><li>38. Travel Consultant</li><li>39. AIDA Plaza<br></li><li>40. Hairdresser<br></li><li>41. MAGNUM Pleasure Store<br></li><li>42. Kids Shop<br></li><li>43. Flower Shop<br></li><li>44. AIDA Shop<br></li><li>45. Treasure Chest<br></li><li>46. Cafe Mare<br></li><li>47. Hemingway Lounge<br></li><li>48. TV Room<br></li><li>49. Photo Gallery<br></li><li>50. Art Gallery<br></li><li>51. Cooking Studio<br></li><li>52. French Kiss - Brasserie<br></li><li>53. Brauhaus<br></li><li>54. Wide World Restaurant<br></li><li>55. Lanai Bar<br></li></ul>"
}, {
"name":"Deck 6",
"description":"<p></p><ul><li>3. Outside Deck<br></li><li>3. Smoking Area<br></li><li>26. Theatre<br></li><li>32. Spray Bar by Moet & Chandon</li><li>39. AIDA Plaza<br></li><li>56. Disco D6<br></li><li>57. Nightclub Nightfly<br></li><li>58. Tapas & Bar<br></li><li>60. Premium Jeweller<br></li><li>61. Travel Shop<br></li><li>62. Photo Studio<br></li><li>63. Casino<br></li><li>64. Prima Bar<br></li><li>65. Casino Bar<br></li><li>66. East Restaurant<br></li><li>67. Ristorante Casa Nova<br></li><li>68. Bella Donna Restaurant<br></li><li>69. Market Restaurant<br></li></ul><p></p>"
}, {
"name":"Deck 5",
"description":"<p></p><ul><li>Cabins<br></li></ul><p></p>"
}, {
"name":"Deck 4",
"description":"<p></p><ul><li>25. Excursion Counter<br></li><li>70. Travel Service<br></li><li>71. Reception<br></li><li>72. Washrooms</li><li>Cabins</li></ul><p></p>"
}, {
"name":"Deck 3",
"description":"<p></p><ul><li>73. Activities Station<br></li><li>74. Gangway<br></li><li>75. Pier 3 Market<br></li><li>76. Conference Room<br></li><li>77. Medical Centre<br></li></ul><p></p>"
}],
"useful_types":[{
"name":"Disabled Facilities",
"description":"<p>You should be able to enjoy the most beautiful time of the year as independently as possible. AIDA therefore ask our guests with reduced mobility, hearing or vision as well as other physical impairments to report at the beginning of the journey at the reception. Here, they will be glad to answer your individual questions about the barrier-free holiday at any time. In case of emergency, you will be provided with crew members who are sure to accompany you to your assembly area.</p>"
}, {
"name":"Smoking Restrictions",
"description":"<p>With regard to the health and well-being of guests, all cabins and public areas of our ships are non-smoking areas . For guests who smoke, the cabin balconies as well as designated smoking areas are available on the outside decks.</p>"
}, {
"name":"Dress Code",
"description":"<p>AIDA is holiday with a smile and without any compulsion. They ask you, however, not to visit restaurants and bars in bathing or sportswear and not barefoot. They recommend men wear long trousers in the evening in the restaurant .</p>"
}],
"cruises":[
{
"id": "VVV000111",
"name": "Super Cruise",
"cruise": "https://www.widgety.co.uk/api/cruises/VVV000111.json"
}
]
}
]
}
因为有点大,我让你知道它是怎样的。
有主舰。船有标题、id、个人资料图像等。这些都保存到我的数据库中。但在 Ship_facts 这样的选项中,有一个数组 { launch_year, width etc... } 并与字符串数组一起保存在我的数据库中。
我的PHP代码是这样的:
<?php
require '../config.php';
$string = file_get_contents("newjson11.json");
$arr = json_decode($string, true);
for ($i = 0; $i < 788; $i++) {
$title = $arr['ships'][$i]['title'];
$id = $arr['ships'][$i]['id'];
$profile_image = $arr['ships'][$i]['profile_image_href'];
$cover_image = $arr['ships'][$i]['cover_image_href'];
$href = $arr['ships'][$i]['href'];
$html_href = $arr['ships'][$i]['html_href'];
$size = $arr['ships'][$i]['size'];
$style = $arr['ships'][$i]['style'];
$gratuities = $arr['ships'][$i]['gratuities'];
$ship_facts = $arr['ships'][$i]['ship_facts'];
$dining = $arr['ships'][$i]['dining'];
$operator = $arr['ships'][$i]['operator'];
//I tried :
// 1. $deckplans = $arr['ships'][$i]['deckplans']['name'];
// 2. $deckplans = $arr['ships'][$i]['deckplans'][$i]['name'];
// 3. $deckplans = $arr['ships']['deckplans']['name'];
// 4. $deckplans = $arr['ships']['deckplans'][$i]['name'];
$deckplans = $arr['ships'][$i]['deckplans'];
$cruises = $arr['ships'][$i]['cruises'];
$query = "INSERT INTO ships
(title, id, profile_image_href,
cover_image_href, href, html_href,
size, style, gratuities,
ship_facts, dining, deckplans,
operator)";
$query .= "VALUES( '{$title}', '{$id}', '{$profile_image}',
'{$cover_image}', '{$href}', '{$html_href}',
'{$size}', '{$style}', '{$gratuities}',
'{$ship_facts}', '{$dining}', '{$operator}')";
$dataatodb = mysqli_query($con, $query);
if(!$dataatodb){
echo("Error" . mysqli_errno($con));
} else {
echo '<h1>Succesfull Data Transfer</h1>';
}
}
?>
我还尝试使用 implode("",$arr)
存储在数据库中,并使用 explode
来回显和 print_r
但仍然没有任何结果;
请问有人可以帮忙吗?
最佳答案
这是一个您试图放入数据库的 php array()。您可以将该部分编码回 json 字符串并将该字符串保存在数据库中。
$ship_facts = json_encode($arr['ships'][$i]['ship_facts']);
关于php - 使用 PHP 数组将 JSON 内容保存在 Mysql 中 [调试],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44718054/
我在网上搜索但没有找到任何合适的文章解释如何使用 javascript 使用 WCF 服务,尤其是 WebScriptEndpoint。 任何人都可以对此给出任何指导吗? 谢谢 最佳答案 这是一篇关于
我正在编写一个将运行 Linux 命令的 C 程序,例如: cat/etc/passwd | grep 列表 |剪切-c 1-5 我没有任何结果 *这里 parent 等待第一个 child (chi
所以我正在尝试处理文件上传,然后将该文件作为二进制文件存储到数据库中。在我存储它之后,我尝试在给定的 URL 上提供文件。我似乎找不到适合这里的方法。我需要使用数据库,因为我使用 Google 应用引
我正在尝试制作一个宏,将下面的公式添加到单元格中,然后将其拖到整个列中并在 H 列中复制相同的公式 我想在 F 和 H 列中输入公式的数据 Range("F1").formula = "=IF(ISE
问题类似于this one ,但我想使用 OperatorPrecedenceParser 解析带有函数应用程序的表达式在 FParsec . 这是我的 AST: type Expression =
我想通过使用 sequelize 和 node.js 将这个查询更改为代码取决于在哪里 select COUNT(gender) as genderCount from customers where
我正在使用GNU bash,版本5.0.3(1)-发行版(x86_64-pc-linux-gnu),我想知道为什么简单的赋值语句会出现语法错误: #/bin/bash var1=/tmp
这里,为什么我的代码在 IE 中不起作用。我的代码适用于所有浏览器。没有问题。但是当我在 IE 上运行我的项目时,它发现错误。 而且我的 jquery 类和 insertadjacentHTMl 也不
我正在尝试更改标签的innerHTML。我无权访问该表单,因此无法编辑 HTML。标签具有的唯一标识符是“for”属性。 这是输入和标签的结构:
我有一个页面,我可以在其中返回用户帖子,可以使用一些 jquery 代码对这些帖子进行即时评论,在发布新评论后,我在帖子下插入新评论以及删除 按钮。问题是 Delete 按钮在新插入的元素上不起作用,
我有一个大约有 20 列的“管道分隔”文件。我只想使用 sha1sum 散列第一列,它是一个数字,如帐号,并按原样返回其余列。 使用 awk 或 sed 执行此操作的最佳方法是什么? Accounti
我需要将以下内容插入到我的表中...我的用户表有五列 id、用户名、密码、名称、条目。 (我还没有提交任何东西到条目中,我稍后会使用 php 来做)但由于某种原因我不断收到这个错误:#1054 - U
所以我试图有一个输入字段,我可以在其中输入任何字符,但然后将输入的值小写,删除任何非字母数字字符,留下“。”而不是空格。 例如,如果我输入: 地球的 70% 是水,-!*#$^^ & 30% 土地 输
我正在尝试做一些我认为非常简单的事情,但出于某种原因我没有得到想要的结果?我是 javascript 的新手,但对 java 有经验,所以我相信我没有使用某种正确的规则。 这是一个获取输入值、检查选择
我想使用 angularjs 从 mysql 数据库加载数据。 这就是应用程序的工作原理;用户登录,他们的用户名存储在 cookie 中。该用户名显示在主页上 我想获取这个值并通过 angularjs
我正在使用 autoLayout,我想在 UITableViewCell 上放置一个 UIlabel,它应该始终位于单元格的右侧和右侧的中心。 这就是我想要实现的目标 所以在这里你可以看到我正在谈论的
我需要与 MySql 等效的 elasticsearch 查询。我的 sql 查询: SELECT DISTINCT t.product_id AS id FROM tbl_sup_price t
我正在实现代码以使用 JSON。 func setup() { if let flickrURL = NSURL(string: "https://api.flickr.com/
我尝试使用for循环声明变量,然后测试cols和rols是否相同。如果是,它将运行递归函数。但是,我在 javascript 中执行 do 时遇到问题。有人可以帮忙吗? 现在,在比较 col.1 和
我举了一个我正在处理的问题的简短示例。 HTML代码: 1 2 3 CSS 代码: .BB a:hover{ color: #000; } .BB > li:after {
我是一名优秀的程序员,十分优秀!