Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,917 members, 7,806,666 topics. Date: Tuesday, 23 April 2024 at 08:24 PM

Search Multiple Tables - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Search Multiple Tables (1024 Views)

Nairaland Uses Tables!! / How To Add Up Tables Using Php / Connecting Two Tables N Display Similar Ids (2) (3) (4)

(1) (Reply) (Go Down)

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"wink or die(mysqli_error());
$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'"wink;
$get_pic_row = mysqli_fetch_assoc($check_pic);
$profile_pic_db = $get_pic_row['profile_pic'];
if ($profile_pic_db == ""wink{
$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"wink or die(mysqli_error());

$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'"wink;
while($row = (mysqli_fetch_assoc($check))) {
$profi = $row['company_picture'];
}
if ($profi == ""wink {
$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"wink or die(mysqli_error());

$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'"wink;
while($row = (mysqli_fetch_assoc($check))) {
$profi = $row['company_picture'];
}
if ($profi == ""wink {
$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)

Programmer Needed For An It Infrastructure Company / I Need Help With SPSS / Network Security Tools! Super Scan 4 Port Scanner Latest Version

(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. 35
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.