i am trying to fetch some record and i wanted to check if previous id was equal to current id then echo something but for the second time the second if doesn't work ! and its just retrieve just one record !
$result= mysql_query (" SELECT * FROM (( SELECT * FROM ((SELECT post_id FROM er_postmeta WHERE meta_key = 'app' AND meta_value = '1' ) po) INNER JOIN er_posts me ON po.post_id = me.ID AND me.post_status='publish') po2 ) INNER JOIN er_postmeta me2 ON po2.ID = me2.post_id ")
or die(mysql_error());
$arr_post_title="";
$arr_post_type="";
$arr_ID="";
$temp=array();
$row2 = mysql_fetch_assoc($result);
$temp1=$row2['ID'];
while ($row = mysql_fetch_assoc($result)) {
if($row['ID']==$temp1)
{
$arr_ID=$row['ID'];
$arr_post_type=$row['post_type'];
$arr_post_title=$row['post_title'];
}
if ($row['ID'] != $temp1)
{
echo "{";
echo '"' . "ID".'"'. ":" .'"'.$arr_ID.'"'."," ;
echo '"' . "Post_Type".'"'. ":" .'"'.$arr_post_type.'"'."," ;
echo '"' . "Post_Title".'"'. ":" .'"'.$arr_post_title.'"'."," ;
echo "},";
$temp1=$row['ID'];
}
}
Aucun commentaire:
Enregistrer un commentaire