1

機能があります

public function get_detail($subscriberid)
    {
    $bigArray = array();

    $result = mysql_query("SELECT *  from prospect_requests WHERE subscriber_id = '$subscriberid'");
    //$user_data = mysql_fetch_array($result);
    $no_rows = mysql_num_rows($result);

    while( $row = mysql_fetch_assoc( $result))
    {

$bigArray[] = $row;
    }
     return json_encode($bigArray);

    }

HTMLのユーザークラスオブジェクトを使用してこの関数を呼び出しており、フォーム配列でデータを返しています。

私は自分のhtmlテーブルにそれらの値を入力しようとしています私は次の方法を使用していますか

<table>
 <?php
 $ary = json_decode($user->get_detail($uid));
         echo "<tr>"         
         foreach($ary as $key=>$value) {
              echo "<td>";
              print  $key['$value'];
              echo "</td>";
           }
   echo "</tr>";

  ?>

上記のforeachは私のために印刷されていません

しかし、私が印刷しているとき、print_r($ary); 私は配列のdesire配列を取得しています。

値がテーブルに入力されない理由を教えてください。

print_r($ ary)の出力を更新します

Array ( [0] => stdClass Object ( [id] => 133 [customer_id] => caason [subscriber_id] => ELECTRO_SUBS_12800 [extension_id] => [vendor_number] => [product_code] => [prospect_email1] => naveen.ggg@bhng.com [prospect_phone1] => +575445 [prospect_email2] => [prospect_phone2] => [prospect_title] => IT Engineer [prospect_company] => gggg [prospect_name] => ggdf [prospect_message] => MESSAGE [create_timestamp] => 2012-12-20 16:28:46 [update_timestamp] => 2012-12-20 16:33:15 [status] => 0 [track_id] => 201660a2-4a66-11e2-abeb-00151771ff65 [initiated_by] => SMS [subscriber_email] => g.dgdg@gfg.com [vendor_email] => ananda.rao@talismanuc.com ) [1] => stdClass Object ( [id] => 134 [customer_id] => caason [subscriber_id] => ELECTRO_SUBS_12800 [extension_id] => [vendor_number] => [product_code] => 12800 [prospect_email1] => gpadaki@sadhanasystems.com [prospect_phone1] => +756767863 [prospect_email2] => [prospect_phone2] => [prospect_title] => TESTING232 [prospect_company] => Sadhana Systems [prospect_name] => 7dfgfg [prospect_message] => MESSAGE [create_timestamp] => 2012-12-22 02:43:51 [update_timestamp] => 2012-12-22 22:42:36 [status] => 0 [track_id] => 380024bc-4b85-11e2-abeb-00151771ff65 [initiated_by] => SMS [subscriber_email] => naveen.fgf@ggf.com [vendor_email] => g.f@talismanuc.com ) [2] => stdClass Object ( [id] => 135 [customer_id] => caason [subscriber_id] => ELECTRO_SUBS_12800 [extension_id] => [vendor_number] => [product_code] => 12800 [prospect_email1] => naveen.vghg@hgh.com [prospect_phone1] => +25454 [prospect_email2] => [prospect_phone2] => [prospect_title] => Sw Engineer [prospect_company] => Talisman [prospect_name] => Naveen [prospect_message] => MESSAGE [create_timestamp] => 2013-01-02 16:32:38 [update_timestamp] => 2013-01-02 16:35:48 [status] => 0 [track_id] => d1da0adc-549d-11e2-abeb-00151771ff65 [initiated_by] => SMS [subscriber_email] => naveen.ggjg@hgjh.com [vendor_email] => gf.fhg@hgh.com ).......))
4

2 に答える 2

1

これを試して:

json_decode($user->get_detail($uid), true);

参照:http://php.net/manual/en/function.json-decode.php

TRUEの場合、返されたオブジェクトは連想配列に変換されます。

于 2013-01-22T12:01:56.327 に答える
0

json_decode -JSONでエンコードされた文字列を取得し、PHP変数に変換します。

mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )

assoc-の場合TRUE、返されたオブジェクトは連想配列に変換されます。

json_decode($user->get_detail($uid), TRUE);

値に配列としてアクセスする場合。

于 2013-01-22T12:04:34.663 に答える