hksfho hksfho - 3 years ago 152
JSON Question

how to select mysql in multi table and mix in one json?

This is my first table

SELECT * FROM tb_chat WHERE senderid = "1"


"sendtime":"2015-10-04 23:31:35",

This is my second table

SELECT * FROM `tb_user` WHERE id = "1"



I want to mix two tables in to one json using php
the tb_chat.senderid = tb_user.userid

enter image description here

Answer Source

NO Code so a logical answer is provided , do your stuff as below-

$result =mysqli_fetch_assoc(mysqli_query(SELECT * FROM tb_chat WHERE senderid = "1"));
$result2 =mysqli_fetch_assoc(mysqli_query(SELECT * FROM  `tb_user` WHERE id =  "1"));
echo json_encode($result);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download