php - Multiple mysql query combining to make json object -


I have a problem with multiple mysql questions and json objects I

  • user_name
  • user_email
  • user_email

  • user_contact

    1. Sender < / Li>
    2. Receiver
    3. Approved

    I get the contact list from the second table with the description from the first table where the concept is defined below in the mysql query has been done. (I.e. the user wants to list all their contact details (with description from user_table) where the sender is a user or the receiver user is 1.)

    The main function, Jason object

     "{Name}", "user_name": "name1", "user_fullname": "full name", "user_email": "example @ example com", "approval": "1"}, { "USER_NAME": "NAME2", "user_fullname": "fullname2", "user_email": "example2@example.com", "approval": "0"}]}  

    me Two tables need to be combined I wrote this,

      $ result = mysql_query ("SELECT * FROM to user_contact 'where' adder '= $ user_id or (` receiver` = $ user_id and' approve = 1 ') " ); $ Rows = array (); $ Count = mysql_num_rows ($ result); If ($ calculation> gt;) {while ($ r = mysql_fetch_assoc ($ result)) {$ rows [] = $ r; } Echo json_encode (array ('contact' = & gt; $ rows)); } And {$ response ["error"] = 1; $ Response ["error_msg"] = "You do not have any contacts yet."; Echo json_encode ($ response); }  

    The above code exchanges JSN data from only one table.

    Thanks in advance

  • I have mentioned above the combination of two tables, how can get json.

    Comments