title: display image limit one per result?
body: <p>I have a search script i am using. it finds users by name or location. i am trying to add a image to each user that is found in the search. but when i do it lists every users image even if not in the search and duplicates the searched name and image a dozen times like so:</p>
  
  <p>image1.jp  user: michael
  image1.jp  user: michael
  image1.jp  user: michael
  image1.jp  user: michael
  image1.jp  user: michael
  image1.jp  user: michael</p>
  
  <p>image2.jp  user: eric
  image2.jp  user: eric
  image2.jp  user: eric
  image2.jp  user: eric
  image2.jp  user: eric
  image2.jp  user: eric</p>
  
  <p>and so on. can someone please let me know how i can limit it to just show one image for each user profile that comes up in the search without limiting the users that show up in the search to 1 obviously?</p>
  
  <p>Heres my code:</p>
  
  <pre><code>&lt;form method="get" action=""&gt;
  &lt;input type="text" name="query" class="search" placeholder="Search Name/Location" style="width:120px;"/&gt;
  &lt;input type="image" src="../PTB1/assets/img/icons/loginarrow1.png" class="searchbutton" name="submit" value="Start Search" /&gt;
  &lt;/form&gt;
  
  &lt;?php
  //PHP CODE STARTS HERE
  
  if(isset($_GET['submit'])){
  
  // Change the fields below as per the requirements
  $db_host="localhost";
  $db_username="root";
  $db_password="";
  $db_name="playtime";
  $db_tb_atr_name="display_name";
  
  //Now we are going to write a script that will do search task
  // leave the below fields as it is except while loop, which will display results on screen
  
  mysql_connect("$db_host","$db_username","$db_password");
  mysql_select_db("$db_name");
  
  $query=mysql_real_escape_string($_GET['query']);
  
  $query_for_result=mysql_query("SELECT *
                          FROM ptb_profiles
                          WHERE display_name like '%".$query."%' 
          OR location LIKE '%".$query."%' OR orientation LIKE '%".$query."%'");
  echo "&lt;div class=\"results\"&gt;";
  while($data_fetch=mysql_fetch_array($query_for_result))
  {
          $search_set = get_searched_escorts();
          while ($searched = mysql_fetch_array($search_set)) {
      echo "&lt;div class=\"spacing\"&gt;&lt;a href=\"profile.php?id={$data_fetch['user_id']}\" class=\"search\"&gt;";
      echo "&lt;img width=80px height= 80px src=\"data/photos/{$searched['id']}/_default.jpg\" class=\"boxgrid\"/&gt; "; 
       echo substr($data_fetch[$db_tb_atr_name], 0,160);
      echo "&lt;/a&gt;&lt;/div&gt;";
  
  }
  }
  
  mysql_close();
  }
  
  ?&gt;
  </code></pre>
  
  <p>Thank you.</p>