Jump to content


Photo

Search is duplicating?


  • Please log in to reply
1 reply to this topic

#1 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 28 September 2006 - 02:17 PM

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 http://www.theevento...rch_members.php 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.
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>
		';
	
	}
	}

}

Thanks for any help given.
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com

#2 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 28 September 2006 - 03:03 PM

I think its displaying all of the results at once.
For example, if i type spires
It will display a profile for every spires in every field in the database.

Any suggestions please
How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users