Jump to content

Search is duplicating?


spires

Recommended Posts

Hi,

Has does anyone here know why my search results are duplicating.

If i type into any of my box i get duplicated results, however if i add a category first,
The result come out correct.
Please goto [URL=http://www.theeventorganiser.com/search_members.php]http://www.theeventorganiser.com/search_members.php[/URL] and see for your self, i'm not to good at explaining.

Here is my code. I'm pulling all the info out of five tables.
[code]
if (isset($_POST['submit_form'])) {

$country=$_POST['country'];
$keywords=$_POST['keywords'];
$company_name=$_POST['company_name'];
$sub = $_POST['sub'];
$cat = $_POST['cat'];
$dist = $_POST['dist'];
$rep = $_POST['rep'];
$hires = $_POST['hires'];
$inst = $_POST['inst'];
$sells = $_POST['sells'];
$manu = $_POST['manu'];

$flag = 0;

$key_query = "SELECT * FROM (user_info LEFT JOIN users_categories ON user_info.id = users_categories.user_id) LEFT JOIN general_profile ON user_info.id = general_profile.profile_id LEFT JOIN availability_profile ON user_info.id = availability_profile.ava_id LEFT JOIN personal_profile ON user_info.id = personal_profile.pers_id";

if (!empty($keywords)) {
$key_query .= "
WHERE (username LIKE '%".$keywords."%' || first_name LIKE '%".$keywords."%' || last_name LIKE '%".$keywords."%' || location LIKE '%".$keywords."%' || email LIKE '%".$keywords."%' || url LIKE '%".$keywords."%' || general_profile.description LIKE '%".$keywords."%' || general_profile.history LIKE '%".$keywords."%' || general_profile.experience LIKE '%".$keywords."%' || general_profile.equipment LIKE '%".$keywords."%' || general_profile.hire_information LIKE '%".$keywords."%' || general_profile.other_requirments LIKE '%".$keywords."%'
|| availability_profile.descr LIKE '%".$keywords."%' || availability_profile.mon LIKE '%".$keywords."%' || availability_profile.tue LIKE '%".$keywords."%' || availability_profile.wed LIKE '%".$keywords."%' || availability_profile.thur LIKE '%".$keywords."%' || availability_profile.fri LIKE '%".$keywords."%' || availability_profile.sat LIKE '%".$keywords."%' || availability_profile.sun LIKE '%".$keywords."%' || personal_profile.age LIKE '%".$keywords."%' || personal_profile.religion LIKE '%".$keywords."%' ||
personal_profile.about LIKE '%".$keywords."%' || personal_profile.hobbies LIKE '%".$keywords."%' || personal_profile.education LIKE '%".$keywords."%' || personal_profile.music LIKE '%".$keywords."%' || personal_profile.Tevents LIKE '%".$keywords."%' || personal_profile.Tmag LIKE '%".$keywords."%' || personal_profile.Tradio LIKE '%".$keywords."%')";
$flag++;
}

if (!empty($company_name)) {
if ($flag==0) {
$key_query .= " WHERE company_name='$company_name'";
$flag++;
}else{
$key_query .= " && company_name='$company_name'";
}
}
if (!empty($cat)) {
if ($flag==0) {
$key_query .= " WHERE user_cats='$cat'";
$flag++;
}else{
$key_query .= " && user_cats='$cat'";
}
}
if (!empty($sub)) {
if ($flag==0) {
$key_query .= " WHERE user_subs='$sub'";
$flag++;
}else{
$key_query .= " && user_subs='$sub'";
}
}
if (!empty($sells)) {
if ($flag==0) {
$key_query .= " WHERE sales='$sells'";
$flag++;
}else{
$key_query .= " && sales='$sells'";
}
}
if (!empty($hires)) {
if ($flag==0) {
$key_query .= " WHERE hire='$hires'";
$flag++;
}else{
$key_query .= " && hire='$hires'";
}
}
if (!empty($rep)) {
if ($flag==0) {
$key_query .= " WHERE rep='$rep'";
$flag++;
}else{
$key_query .= " && rep='$rep'";
}
}
if (!empty($inst)) {
if ($flag==0) {
$key_query .= " WHERE inst='$inst'";
$flag++;
}else{
$key_query .= " && inst='$inst'";
}
}
if (!empty($manu)) {
if ($flag==0) {
$key_query .= " WHERE manu='$manu'";
$flag++;
}else{
$key_query .= " && manu='$manu'";
}
}
if (!empty($dist)) {
if ($flag==0) {
$key_query .= " WHERE manu='$manu'";
$flag++;
}else{
$key_query .= " && dist='$dist'";
}
}



$key_result = mysql_query($key_query) or die ("query 2 failed".mysql_error());
$key_count = mysql_num_rows($key_result);
echo $key_count.'<br>';


while ($key_row = mysql_fetch_array($key_result)) {
$key_id = $key_row['id'];
$username = $key_row['username'];


$img_query = "SELECT * FROM (user_info LEFT JOIN thumb ON user_info.id = thumb.thumb_id) LEFT JOIN general_profile ON user_info.id = general_profile.profile_id  LEFT JOIN main_cats ON user_info.id = main_cats.uid WHERE user_info.id='$key_id'";
$img_result = mysql_query($img_query) or die ("query thumb failed".mysql_error());
$img_count = mysql_num_rows($img_result);

while ($img_row = mysql_fetch_array($img_result)) {
$new_img_name = $img_row['new_img_name'];
$sell1 = $img_row['sales'];
$install1 = $img_row['inst'];
$hire1 = $img_row['hire'];
$manu1 = $img_row['manu'];
$rep1 = $img_row['rep'];
$dist1 = $img_row['dist'];
$descr = $img_row['description'];
$main_cat = $img_row['main_cat'];
$main_sub = $img_row['main_sub'];

echo '<center><TABLE  width="650" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD align="center">
<br><TABLE class="TLRB_border" bgcolor="#EEEEEE" width="650" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD width="129">'.$username.'</TD>
<TD width="183">Main Cat: '.$main_cat.'</TD>
</TR>
<TR>
<TD width="129" rowspan="5" bgcolor="#FFFFFF" align="center"><img src="thumb2/'.$new_img_name.'"></TD>
<TD height="70" bgcolor="#FFFFFF" colspan="2" class="TLRB_border" >'.$descr.'</TD>
</TR>
<tr>
<td>SALES: '.$sell1.'</td>
<td>INSTALS: '.$install1.'</td>
</tr>
<tr>
<td>HIRES: '.$hire1.'</td>
<td>MANU: '.$manu1.'</td>
</tr>
<tr>
<td>REPAIRS: '.$rep1.'</td>
<td>DIST: '.$dist1.'</td>
</tr>
</table></center>
';

}
}

}
[/code]

Thanks for any help given.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.