小编Dan*_*ers的帖子

php - Foreach - 包含<li> </ li>,里面有两个结果,然后重复.

使用php - 我试图在数组上运行"foreach",但我想将每两个结果包装在li标签中.输出将如下所示.

<li>

<div>result 1</div>

<div>result 2</div>

</li>

<li>

<div>result 3</div>

<div>result 4</div>

</li>

<li>

<div>result 5</div>

<div>result 6</div>

</li>

我该怎么做呢?

谢谢!

php arrays foreach counter html-lists

3
推荐指数
1
解决办法
4102
查看次数

Titanium - 无法解析本地JSON文件

我试图解析已存储在applicationDataDirectory中的本地JSON文件.我只需要从这个文件中获取项目.运行钛的V.2

JSON数据结构如下所示

{
"object_name": [
    {
        "title": "Burrton",
        "value": "Burrton",
        "homeof": "Chargers",
        "logo": "images/logos/BURRTON.jpg",
        "colors": "#cccccc;#a9a9a9",
        "links": {
            "tsr": "http://www.schurzdigital.com/mfeeds/CollectionFeed.php?site=http%3A%2F%2Fwww.catchitkansas.com&collection=cik_burrton_headlines&title=cik_burrton_headlines&limit=25",
            "sports": "www.schurzdigital.com/mfeeds/CollectionFeed.php?site=http%3A%2F%2Fwww.catchitkansas.com&collection=cik_burden_headlines&title=cik_burden_headlines&limit=25",
            "videos": "http://www.schurzdigital.com/mfeeds/TividFeedConvert.php?site=http%3A%2F%2Fwww.catchitkansas.com&slug=e9c0b075-3230-4a45-803e-7ccb4b7f754e&title=Top%20videos&limit=25",
            "photos": "http://serve.a-feed.com/service/getFeed.kickAction?feedId=1014509&as=8768",
            "stats": {
                "boys": {
                    "football": "http://stats.catchitkansas.com/report_fb-schedule_results.php?sport=15&team=763",
                    "basketball": "http://stats.catchitkansas.com/report_baskb-schedule_results.php?sport=26&team=2946",
                    "cross country": "http://stats.catchitkansas.com/report_cc-schedule_results.php?sport=13&team=764",
                    "golf": "http://stats.catchitkansas.com/report_golf-schedule_results.php?sport=16&team=767",
                    "track": "http://stats.catchitkansas.com/report_trackfield-schedule_results.php?sport=32&team=2948"
                },
                "girls": {
                    "volleyball": "http://stats.catchitkansas.com/report_vb-schedule_results.php?sport=22&team=766",
                    "basketball": "http://stats.catchitkansas.com/report_baskb-schedule_results.php?sport=27&team=2947",
                    "cross country": "http://stats.catchitkansas.com/report_cc-schedule_results.php?sport=13&team=764",
                    "golf": "http://stats.catchitkansas.com/report_golf-schedule_results.php?sport=17&team=768",
                    "track": "http://stats.catchitkansas.com/report_trackfield-schedule_results.php?sport=32&team=2948"
                }
            }
        }
    }
]
}
Run Code Online (Sandbox Code Playgroud)

我使用的代码来解析文件.

var fileName = 'school_select.json';
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, fileName);

if (file.exists()) {
  var json = file.read();
  var jsonObject …
Run Code Online (Sandbox Code Playgroud)

parsing json local titanium titanium-mobile

1
推荐指数
1
解决办法
3830
查看次数

PHP SQL - 由于","导致按日期排序失败

我有一个非常奇怪的问题.我正在查询数据并将其格式化为json.格式工作得很好,但是当我尝试添加一个案例来防止,出现在json的最后一项时,我的SQL语句的"按日期排序"不起作用,我只是通过ID命令它.有什么想法?

$sql = "SELECT * FROM events ORDER BY date";
$res = mysql_query($sql,$con);
$number = mysql_num_rows($res);
$json = 'var event_data={';
$i = 1;
while ($row = mysql_fetch_assoc($res))
    {
    $json .= '"'.$row['id'].'": {';
    $json .= '"loc_id":"'.$row['loc_id'].'"';
    $json .= ', "type":"'.$row['type'].'"';
    $json .= ', "time":"'.$row['time'].'"';
    $json .= ', "date":"'.$row['date'].'"}';
    if ($i < $number)
       {
           $json .= ',';  //<----- this is the problem child
       }else{
           $json .= '';
       }
     $i ++;
    }
$json .= '};';  
echo $json;
Run Code Online (Sandbox Code Playgroud)

php mysql sql json while-loop

0
推荐指数
1
解决办法
73
查看次数