Stats: 3,190,617 members, 7,941,367 topics. Date: Friday, 06 September 2024 at 04:20 AM |
Nairaland Forum / Science/Technology / Programming / Search Multiple Tables (1035 Views)
Nairaland Uses Tables!! / How To Add Up Tables Using Php / Connecting Two Tables N Display Similar Ids (2) (3) (4)
Search Multiple Tables by skyhighweb(m): 12:19pm On Apr 06, 2017 |
hi i have this code and i want to include a second table to it how do i go about it if (isset($_SESSION['advs']) && is_array($_SESSION['advs'])) { $searching = true; if (!empty($_SESSION['advs']['title'])) { $wher .= '('; if (isset($_SESSION['advs']['desc'])) { $wher .= "(au.description LIKE :likedescription) OR "; $asparams[] = array(':likedescription', '%' . $system->cleanvars($_SESSION['advs']['title']) . '%', 'str'); } $wher .= "(au.title like :liketitle OR au.id = :idtitle)) AND "; $asparams[] = array(':idtitle', intval($_SESSION['advs']['title']), 'int'); $asparams[] = array(':liketitle', '%' . $system->cleanvars($_SESSION['advs']['title']) . '%', 'str'); } want to include subtitle as the second query so i i can search both title and subtitle on one form field, need assistance thanks |
Re: Search Multiple Tables by skyhighweb(m): 7:26pm On Apr 07, 2017 |
any assistance |
Re: Search Multiple Tables by Jenifa123: 4:41pm On Apr 08, 2017 |
Hmmm Kinda busy now.. Will put up a solution b4 9pm Since I don't have all d time to write d codes. Lemme share one I used of recent if(isset($_POST['vpv_search_box']) && !empty($_POST['vpv_search_box'])) { $searchq = $_POST['vpv_search_box']; $searchq = preg_replace("#[^0-9a-z - . _]#","",$searchq); $search_for_people = mysqli_query($conn,"SELECT * FROM friendzone WHERE first_name LIKE '%$searchq%' OR last_name LIKE '%$searchq%' OR username LIKE '%$searchq%' order by `id` desc limit 4" ![]() $count = mysqli_num_rows($search_for_people); if(mysqli_num_rows($search_for_people) > 0) { ?> <li class="vpb_titles"><span class="text">People</span></li> <?php while ($row = mysqli_fetch_array($search_for_people)) { $fname = $row['first_name']; $lname = $row['last_name']; $id = $row['id']; $user=$row['username']; $check_pic = mysqli_query($conn,"SELECT profile_pic FROM friendzone WHERE username='$user'" ![]() $get_pic_row = mysqli_fetch_assoc($check_pic); $profile_pic_db = $get_pic_row['profile_pic']; if ($profile_pic_db == "" ![]() $profile_pic = "img/default_pic.png"; } else { $profile_pic = "userdata/profile_pics/".$profile_pic_db; } ?> <li> <?php echo $output .= "<div>'<li><a href=$user><img src='$profile_pic' height='25' width='25'>' <a href=$user>$row[username] </a></li></div><br />'"; ?> </li> <?php } $search_for_pages = mysqli_query($conn,"SELECT * FROM Pages WHERE company_name LIKE '%$searchq%' OR company_username LIKE '%$searchq%' order by `id` desc limit 2" ![]() $count = mysqli_num_rows($search_for_pages); if(mysqli_num_rows($search_for_pages) > 0) { ?> <li class="vpb_titles"><span class="text">Pages</span></li> <?php while ($row = mysqli_fetch_assoc($search_for_pages)) { $id = $row['id']; $company_name = $row['company_name']; $company_username = $row['company_username']; $company_picture = $row['company_picture']; $company_background_pic = $row['company_background_pic']; $user_like_company = $row['user_like_company']; } $check = mysqli_query($conn,"SELECT company_picture FROM Pages WHERE company_username='$company_username'" ![]() while($row = (mysqli_fetch_assoc($check))) { $profi = $row['company_picture']; } if ($profi == "" ![]() $my_cover = "../img/biz.jpg"; } else{ $my_cover = "../userdata/page_profile_pics/".$profi; } ?> <li> <?php echo $output .= "<div>'<li><a href=./pages/$company_username><img src='$my_cover' height='25' width='25'>' <a href=./pages/$company_username>$row[company_username] </a></li></div><br />'"; ?> </li> <?php } else { //Do nothing as our major reason for seaching are people and not pages } ?> <li class="more"> <a href="javascript:void(0);" onclick="alert('LOL');"> <span class="text">See more result for <?php echo $search_term; ?> <img src="images/vpb_arrow.png" alt="" border="0"></span> <span class="category">Displaying top <?php echo mysqli_num_rows($search_for_people)+mysqli_num_rows($search_for_pages); ?> results</span> </a> </li> <?php } else { $search_for_pages = mysqli_query($conn,"SELECT * FROM Pages WHERE company_name LIKE '%$searchq%' OR company_username LIKE '%$searchq%' order by `id` desc limit 2" ![]() $count = mysqli_num_rows($search_for_pages); if(mysqli_num_rows($search_for_pages) > 0) { ?> <li class="vpb_titles"><span class="text">Pages</span></li> <?php while ($row = mysqli_fetch_assoc($search_for_pages)) { $id = $row['id']; $company_name = $row['company_name']; $company_username = $row['company_username']; $company_picture = $row['company_picture']; $company_background_pic = $row['company_background_pic']; $user_like_company = $row['user_like_company']; } $check = mysqli_query($conn,"SELECT company_picture FROM Pages WHERE company_username='$company_username'" ![]() while($row = (mysqli_fetch_assoc($check))) { $profi = $row['company_picture']; } if ($profi == "" ![]() $my_cover = "../img/biz.jpg"; } else{ $my_cover = "../userdata/page_profile_pics/".$profi; } ?> <li> <?php echo $output .= "<div>'<li><a href=./pages/$company_username><img src='$my_cover' height='25' width='25'>' <a href=./pages/$company_username>$company_username </a></li></div><br />'"; ?> </a> </li> <?php } ?> <li class="more"> <a href="javascript:void(0);" onclick="alert('This is only a demonstration and so, no link is added to this. Thanks...');"> <span class="text">See more result for <?php echo $search_term; ?> <img src="images/vpb_arrow.png" alt="" border="0"></span> <span class="category">Displaying top <?php echo mysqli_num_rows($search_for_pages); ?> results</span> </a> </li> <?php } } |
Re: Search Multiple Tables by skyhighweb(m): 8:52pm On Apr 13, 2017 |
thanks but have solved it |
(1) (Reply)
I Buy Payoneer, Skrill, Perfect Money And Bitcoin At Sweet Rate / Web Developer Needed Urgently. Knowledge Of Php Is An Added Advantage / Explanation Needed In PHP
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20 |