How to put mysql queries into different arrays
Posted: Sun Jun 21, 2015 3:53 am
My Question related to arrays
$Parray=[1,2];
Table Structure:-
BrandName BrandType PostID
sss top 1
fsdds top 1
sr bottom 2
My Query Is:-
for($i=0;$i<sizeof($Parray);$i++){
$sql=mysql_query("SELECT BrandName,BrandPeople from BrandDetails where PostID='Parray[$i]'");
while($row=mysql_fetch_assoc($sql)){
$out[]=$row;
}
}
print json_encode($out);
my out is:- [{"BrandName":"sss","BrandType":"top"},{"BrandName":"fsdds","BrandType":"top"},{"BrandName":"sr","BrandType":"bottom"}]
BUT I NEED tow diffrent arrays for different postids:- {[{"BrandName":"sss","BrandType":"top"},{"BrandName":"fsdds","BrandType":"top"}],[{"BrandName":"sr","BrandType":"bottom"}]}
$Parray=[1,2];
Table Structure:-
BrandName BrandType PostID
sss top 1
fsdds top 1
sr bottom 2
My Query Is:-
for($i=0;$i<sizeof($Parray);$i++){
$sql=mysql_query("SELECT BrandName,BrandPeople from BrandDetails where PostID='Parray[$i]'");
while($row=mysql_fetch_assoc($sql)){
$out[]=$row;
}
}
print json_encode($out);
my out is:- [{"BrandName":"sss","BrandType":"top"},{"BrandName":"fsdds","BrandType":"top"},{"BrandName":"sr","BrandType":"bottom"}]
BUT I NEED tow diffrent arrays for different postids:- {[{"BrandName":"sss","BrandType":"top"},{"BrandName":"fsdds","BrandType":"top"}],[{"BrandName":"sr","BrandType":"bottom"}]}