<?php require_once('Connections/mycon.php'); ?>
<?php
mysql_select_db($database_mycon, $mycon);
$query_Recordset1 = 'SELECT country.name as country, country_Message.name as Message
FROM country, country_Message
WHERE country.id = country_Message.country_id';
//$Recordset1 = mysql_query($query_Recordset1) or die(mysql_error());
$query_Recordset2='select name from country';
$Recordset2=mysql_query($query_Recordset2) or die(mysql_error());
$json_output=array();
$json_countryoutput=array();
while($mainrow=mysql_fetch_assoc($Recordset2))
{
$json_countryoutput[]=array($mainrow['name']=>$mainrow['name'] );
}
mysql_free_result($Recordset2);
$Recordset2=mysql_query($query_Recordset2) or die(mysql_error());
while($mainrow=mysql_fetch_assoc($Recordset2))
{
$Recordset1 = mysql_query($query_Recordset1) or die(mysql_error());
while($row=mysql_fetch_assoc($Recordset1))
{
if(strcmp ( $mainrow['name'] , $row['country'])==0)
{
//echo $row['country'];
$json_output[]=array($mainrow['name']=>$row['Message'] );
/
/$json_output[]1=array('country'=>$row['country'],'Message'=>$row['Message'] );
}
mysql_free_result($Recordset1);
}
//$json_output=array_merge($json_output, $json_countryoutput);
echo json_encode(array('item'=>$json_output,'country'=>$json_countryoutput));
mysql_free_result($Recordset1);
输出:
{"item":[{"German":"Hello"},{"German":"guten Morgen"},{"German":"gute Nacht"},{"English":"Hello"},{"英语":"早安"},{"英语":"晚安"},{"法语":"bonjour"},{"法语":"bonne nuit"},{"法语":"bonjour"} ],"country":[{"German":"German"},{"English":"English"},{"French":"French"}]}
我想改变基本上我有不同的国家和每个国家我想显示所有记录:{“German”:[{“hello”},{“gutton Morgan”}],“English”:[{“”},{ ““}],“法语”:[{””},{””}] }