1

我有一个问题,当我要运行应用程序时,我收到一个 System.err:anotacoes 没有价值!

我认为我的问题出在 php 代码上。如果有人帮助我,我会非常感谢你的帮助。

(对不起,我的英语不好 ;) )

                   <?php


// array for JSON response
$response = array();
$response1 = array();

 mysql_connect("localhost","root",""); // host, username, password...
    mysql_select_db("mobimapa"); // db name...

// check for post data

    $pid = $_GET['pid'];

    // get a product from products table
    $result = mysql_query("SELECT id_anotacao FROM processo_anotacoes WHERE id_processo = $pid");


        // check for empty result
        if (mysql_num_rows($result) > 0) {

            //$response["processo_anotacoes"] = array();

            $processo_anotacoes = array();
             while ($row = mysql_fetch_array($result)){
                array_push($processo_anotacoes, $row["id_anotacao"]); 



           // $processo_anotacoes["id_anotacao"] = $row["id_anotacao"];
           // $processo_anotacoes["id_processo"] = $row["id_processo"];

            // success
            //$response["success"] = 1;

            // user node
           // $response["processo_anotacoes"] = array();


           }
          // echo json_encode($processo_anotacoes); 

 }
$ids = join(', ',$processo_anotacoes);

$result1 = mysql_query("SELECT * FROM anotacoes WHERE id_anotacao IN ($ids)");

    if (mysql_num_rows($result1) > 0) {

        $response1["anotacoes"] = array();

        // check for empty result
        while ($row1 = mysql_fetch_array($result1)) {

            //$result1 = mysql_fetch_array($result1);

            $anotacoes = array();
            $anotacoes["id_anotacao"] = $row1["id_anotacao"];
            $anotacoes["nome"] = $row1["nome"];
            $anotacoes["descricao"] = $row1["descricao"];

            // success
            $response1["success"] = 1;

            // user node
            $response1["anotacoes"] = array();

            array_push($response1["anotacoes"], $anotacoes);
        }
            // echoing JSON response
            echo json_encode($response1);   
    }

?>

08-12 17:09:03.308: D/所有产品:(806): {"success":1,"processo":[{"data":"2013-07-17","id_processo":"1" ,"nome":"进程 1","imagem":"稍后"},{"data":"2013-08-04","id_processo":"2","nome":"进程 2"," imagem":"稍后"}]} 08-12 17:09:03.518: I/Choreographer(806): 跳过 110 帧!应用程序可能在其主线程上做了太多工作。08-12 17:09:29.238: D/Processo clicado(806): 2 08-12 17:09:29.838: D/Single Product Details(806): {"product":[{"data":"2013- 08-04","id_processo":"2","nome":"Processo 2","imagem":"稍后"}],"成功":

4

1 回答 1

0

问题在于传递给第二个 SQL 查询的 PHP 变量。这不是完整的代码;但如果你理解它,它将解决你的问题:

$anotacaos = array();
while ($row = mysql_fetch_array($result))
    array_push($anotacaos, $row["id_anotacao"]);  

$ids = join(',',$anotacaos);  
$result1 = mysql_query("SELECT * FROM anotacoes WHERE id_anotacao in ($ids)");

while ($row = mysql_fetch_array($result1))
    //do something...
于 2013-08-11T18:58:57.467 回答