1
$query_message1 = "select a.new,a.mes_id,a.frm_id,a.mem_id,a.subject,a.body,a.date,a.read from messages_system as a where a.frm_id='$memId' and a.type='message' order by date desc limit $lowerlimit,$limit";
$exeMessage=execute_query($query_message1,true,"select");
$message =$exeMessage;
print_r($message);
foreach($exeMessage as $kk=>$mem){
$query_message2 = "select b.profilenam,b.photo_thumb,b.gender,b.profile_type from members as b where b.mem_id='".$mem['mem_id']."'";
$exeMessage1 = execute_query($query_message2,true,"select");
//print_r($exeMessage);
if (empty($exeMessage1)) {
echo "0";
$img = "images/my-profile-img3-big.gif";
// print_r($message['mes_id']);
$exeMessage1['profilenam']='Annonymous';
$exeMessage1['photo_thumb']=$img;
$exeMessage1['gender']='m';
$exeMessage1['profile_type']='';
$message[$kk] = $exeMessage1;
}
}
もしますprint_r($メッセージ)をreult取得していて、私はこのクエリを持っています。ラインは私に
(
[0] => Array
(
[new] => new
[mes_id] => 1030
[frm_id] => 329
[mem_id] => 39
[subject] => aaaa
[body] => aaaa
[date] => 1310285289
[read] => read
)
[1] => Array
(
[new] => viewed
[mes_id] => 1029
[frm_id] => 329
[mem_id] => 397
[subject] => aaaa
[body] => aaaa
[date] => 1310285188
[read] => read
)
)
とライン$message[$kk] = array_merge($exeMessage1,$message[$kk]);
を与えてくれ条件if (empty($exeMessage1)) {
の結果を与え、今私は、最終的な結果は、この
(
[0] => Array
(
[new] => new
[mes_id] => 1030
[frm_id] => 329
[mem_id] => 39
[subject] => aaaa
[body] => aaaa
[date] => 1310285289
[read] => read
[profilenam] => Annonymous
[photo_thumb] => images/my-profile-img3-big.gif
[gender] => m
[profile_type] =>
)
[1] => Array
(
[new] => viewed
[mes_id] => 1029
[frm_id] => 329
[mem_id] => 397
[subject] => aaaa
[body] => aaaa
[date] => 1310285188
[read] => read
[profilenam] => Purple Test
[photo_thumb] => photos/19db7b14c0ebdb98838fdafb46b3a1ebth.jpeg
[gender] => n
[profile_type] => C
)
)
のようになりますように、これら二つの配列をマージしたい助けてください ありがとう
ここには解決策があります
$query_message1 = "select a.new,a.mes_id,a.frm_id,a.mem_id,a.subject,a.body,a.date,a.read from messages_system as a where a.frm_id='$memId' and a.type='message' order by date desc limit $lowerlimit,$limit";
$exeMessage = execute_query($query_message1, true, "select");
$totalResult = "select a.new,a.mes_id,a.frm_id,a.mem_id,a.subject,a.body,a.date,a.read from messages_system as a where a.frm_id='$memId' and a.type='message' order by date desc";
$exetotalResult = execute_query($totalResult, true, "select");
foreach ($exeMessage as $kk => $mem) {
$query_message2 = "select b.profilenam,b.photo_thumb,b.gender,b.profile_type from members as b where b.mem_id='" . $mem['mem_id'] . "'";
$exeMessage1 = execute_query($query_message2, true, "select");
if (empty($exeMessage1)) {
$img = "images/my-profile-img3-big.gif";
$exeMessage1[$kk]['profilenam'] = 'Annonymous';
$exeMessage1[$kk]['photo_thumb'] = $img;
$exeMessage1[$kk]['gender'] = 'm';
$exeMessage1[$kk]['profile_type'] = '';
}
$message[$kk] = array_merge((array) $mem, (array) $exeMessage1[0]);
}
[array_merge_recursive](http://php.net/manual/en/function.array-merge-recursive.php)を試しましたか? – Zyava
オフトピックでは、ステートメントに値を直接補間するのではなく、準備済みステートメントを使用する必要があります。準備されたステートメントはより安全でパフォーマンスが良い。 – outis