【问题标题】:Designing Html5 Powered Shopping cart ??设计 Html5 驱动的购物车 ??
【发布时间】:2013-12-29 14:06:46
【问题描述】:

我正在开发一个移动购物车,我正在学习这个教程,http://go.developer.ebay.com/devzone/articles/building-html5-powered-shopping-cart-ios-part-1

在本教程中,我将产品作为 Json 转换为 Html。使用以下代码将产品作为 Json iam 获取,

    <?php

// simulates result of db query for categories
$categories = array();
$categories[] = array(id => 1, parent_id => 0, name => 'root');
$categories[] = array(id => 2, parent_id => 1, name => 'Compact Discs');
$categories[] = array(id => 3, parent_id => 1, name => 'Concert Souvenirs');

// simulates result of db query for products
$products = array();
$products[] = array(id => 1, category_id => 2, sku => 'CD001', price=>15.00, name => 'CD: Greatest Hits');
$products[] = array(id => 2, category_id => 2, sku => 'CD002', price=>15.00, name => 'CD: Unplugged');
$products[] = array(id => 3, category_id => 2, sku => 'CD003', price=>15.00, name => 'CD: World Tour');
$products[] = array(id => 4, category_id => 3, sku => 'PD001', price=>10.00, name => 'Souvenir Pin');
$products[] = array(id => 5, category_id => 3, sku => 'PD002', price=>10.00, name => 'Mug');
$products[] = array(id => 6, category_id => 3, sku => 'PD003', price=>20.00, name => 'Hat');
$products[] = array(id => 7, category_id => 3, sku => 'PD004', price=>12.00, name => 'Summer Tour Poster');
$products[] = array(id => 8, category_id => 3, sku => 'PD005', price=>5.00,  name => 'Concert Program');
?>

如果我运行 catalog.php,我会得到 Json 输出,但会出现错误,例如所有行上的未定义常量。 按照上述教程的指示,我力图创建任何表。但是当我访问索引文件时,我得到的只是空白屏幕。

请帮助我获取输出。

【问题讨论】:

  • 如果您包含实际收到的错误消息会很有帮助。

标签: php mysql sql json html


【解决方案1】:

你必须在 php 中引用字符串数组键,否则你会收到关于未定义常量的警告。

$categories[] = array('id' => 2, 'parent_id' => 1, 'name' => 'Compact Discs');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-12
    • 2018-07-04
    • 2018-08-03
    • 1970-01-01
    相关资源
    最近更新 更多