I want to combine these two php mysql queries and want to get one resultset array.
first query gives all members and postby related posts and second query gives all admin related posts with member_id
is 0 and post_by
with 0 and admin_id
is not 0 and super_admin_post
0.
Database:
1) wall_post_master this my first database fields.
wp_id
, wp_cat_id
, wl_text
, wp_img
, datetime
, displevel
, mg_id
, member_id
, admin_id
, family_id
, post_by
, photo_id
, post_category
, generation_id
, visible_to
, highlight
, super_admin_post
2) admin_user_master this my second database fields.
user_id
, family_id
, first_name
, last_name
, password
, email_id
, user_level
Here my conditions to show wallpost data:
1)if mg_id exits with multiple member_id relates to comma.
2)if visible_to exits with multiple member_id relates to comma.
3)if member_id exits with current member_id.
4)if member_id exits in post_by.
5)if member_id is 0 and post_by is 0 and super_admin_post = 0 then i want to display as admin post.
First Query:
$grpsearch = "";
foreach ($arrseltran as $grpid) {
$grpsearch .= " OR ( FIND_IN_SET('" . $grpid . "', wp.mg_id) AND displevel = 3)";
}
if($time == ""){ $time .= " WHERE"; }else{ $time .=" AND"; }
$time .= "
wp.family_id = " . $_SESSION['logft']['family_id'] . " AND
wp.post_category = 0 AND
(
wp.member_id = " . $_SESSION['logft']['member_id'] . " OR
wp.post_by = " . $_SESSION['logft']['member_id'] . " OR
FIND_IN_SET('" . $_SESSION['logft']['member_id'] . "', wp.visible_to) " . $grpsearch . " OR
displevel = 1
)";
$timeline = "SELECT wp.*,
wp.member_id,
wp.datetime AS TimeSpent,
wp_cat.font_color,
photo.photo_path,
mm.first_name,
mm.middle_name,
mm.last_name,
mm1.first_name AS to_first_name,
mm1.middle_name AS to_middle_name,
mm1.last_name AS to_last_name
FROM wall_post_master wp
INNER JOIN
wallpost_cat_master wp_cat ON wp_cat.wp_cat_id = wp.wp_cat_id
INNER JOIN
member_master mm ON mm.member_id = (CASE WHEN (wp.post_by = 0) THEN wp.member_id ELSE wp.post_by END)
INNER JOIN
member_master mm1 ON mm1.member_id = wp.member_id
LEFT JOIN
photo_master photo ON photo.photo_id = mm.photo_id
" . $time ." ORDER BY Timespent DESC";
Second Query:
$timeline1 = "SELECT wpa.*,
wpa.family_id,
wpa.datetime AS TimeSpent,
wp_cat.font_color,
wpa.wp_img,
c.family_id,
c.family_name,
c.editor_photo,
aum.first_name,
aum.last_name
FROM wall_post_master wpa
INNER JOIN
wallpost_cat_master wp_cat ON wp_cat.wp_cat_id = wpa.wp_cat_id
INNER JOIN
config c ON c.family_id = wpa.family_id
INNER JOIN
admin_user_master aum ON aum.family_id = wpa.family_id
where
aum.user_level = 1 and
wpa.admin_id <> 0 and
wpa.family_id='".$_SESSION['logft']['family_id']."' and
wpa.member_id=0 and
wpa.post_by=0 and
wpa.super_admin_post=0
ORDER
BY Timespent DESC";