php - Sql query is not fetching results with variables -
i trying execute sql query using inner join ... code below... part 1 works fine.. , creating value $query_adlist dynamically.. when user variable $query_adlist in part 2, not fetch results.
part 1.
$query_adlist=""; $ad_list_countx=mysql_query("select count(ads_id) ads id=$id"); if($ad_list_countx){$ad_list_count=mysql_fetch_row($ad_list_countx);} if(isset($ad_list_count) && $ad_list_count[0] > 0) { $query_adlist .="&& ("; $query_ad_listx=mysql_query("select ads_id ads id=$id"); if(isset($query_ad_listx)) { $sign=" || "; $count=1; while($query_ad_list=mysql_fetch_array($query_ad_listx)) { if($ad_list_count[0] == $count){$sign=") &&";} $query_adlist .="ad_clicks.ads_id=".$query_ad_list['ads_id'].$sign; $count++; } } }
the value of variable after while loop
$query_adlist="&& (ad_clicks.ad_id=44 || ad_clicks.ad_id=43)";
part 2. when execute code in part 2, not fetch result.. if type ad_clicks.ad_id=44 || ad_clicks.ad_id=43 instead of variable $query_adlist , fetches result.. confuesd. m doing wrong.
$daily_clickx1=mysql_query(" select count(ad_clicks.ad_id) ad_clicks inner join members on ad_clicks.id=members.id members.ref_id1=$id && ad_clicks.date='$date_modified' $query_adlist ");
well mistake .. column name wrong.. figured out later. column name ads_id ad_id
Comments
Post a Comment