tags:

views:

57

answers:

0
<?php
$tab=1;/*$_GET['tab'];*/
$id=1111;/*$_GET['id'];*/
include_once('solve.php');
  $query="SELECT
  user_job.level1,
  user_job.tab_level,
  job.money_gain,
  job.exp_gain,
  job.energy_required,
  job.name,job.job_id
FROM user_job
RIGHT JOIN job USING(job_id) WHERE job.tab=".$tab." AND user_job.user_id=".$id." LIMIT 0,10";
     $result =solve1($query);
        while($data=mysql_fetch_array($result))
        {
            $i=0;
            $rows[]=array('name'=>array(
                                        'name_id'=>$data['name'],
                                        'tab_level'=>$data['tab_level']
                                        ),
                          'job_reward'=>array(
                                        'job_money'=>$data['money_gain'],
                                        'job_exp'=>$data['exp_gain'],
                                        'job_energy'=>$data['energy_required']
                                        )


                        );
                    echo $data['job_id'];
                    $q="SELECT job_item.no,job_item.item_name FROM job_item WHERE job_id=".$data['job_id'];
                    $data_result=solve1($q);
                    $re=array();
                    $data_data="";
                    while($data_data=mysql_fetch_array($data_result))       
                    {
                        $r=array( 'filename'=>$data_data['item_name'],
                                  'no'=>$data_data['no']
                                  );

                        array_push($re,$r);
                    }
                    //print_r(json_encode($re));
                    $rows['job_required_items']=$re;
                    //echo $data['job_id']."==>".var_dump($re);
                    //$rows['job_required_items']=$r;
                    //$rows['']
                    //$rows[$i]=$rows[$i]+$re;
                    //array_merge($rows[$i],$re['job_required_items']);
                    //array_push($rows[$i],re);
                    //print_r($re);
                    //$row[]=array('job_required_items'=>array());                  
                    //$rows[$i]=$rows[$i]+$re;
                    $r=array();
                    $re=array();
                    //unset($r);
                    //unset($re['job_required_items']);
                //print_r(json_encode($re));                                
                        //($rows);              
            $i++;
        }
        //print_r($rows);
        print_r(json_encode($rows));





?>

I am getting this

{"0":{"name":{"name_id":"How to battle","tab_level":"2"},"job_reward":{"job_money":"10000","job_exp":"50","job_energy":"23"}},"job_required_items":[{"filename":"sowrd.gif","no":"2"},{"filename":"pistol.gif","no":"2"}],"1":{"name":{"name_id":"Check for battle","tab_level":"2"},"job_reward":{"job_money":"1000","job_exp":"12","job_energy":"10"}}}

but i also want job_required_items in second array

Help