javascript - PHP & SQL search system variable issue -


i'm trying create player search system searches through sql database. working when try create more info popup player variables don't work.

the php & js code:

$(document).on('click', '#search-result', function(){      $("#mydiv").fadein();  });    $(document).on('click', '#close', function(){      $("#mydiv").fadeout();   });
<?php  $output = null;    if(isset($_post['submit'])) {      $mysqli = new mysqli ("localhost", "root", "", "textus");        $search = $mysqli->real_escape_string($_post['search']);        $resultset = $mysqli->query("select * players player_name '%$search%' order kills desc limit 10");        if($resultset->num_rows > 0) {          while($rows = $resultset->fetch_assoc())          {              $player_name = $rows['player_name'];              $kills = $rows['kills'];              $current_team = $rows['current_team'];                $output = " <div id=\"mydiv\">\n                          <div id=\"player-popup-name\">$player_name</div>                          <div id=\"close\">x</div>\n                          <img id=\"player-popup-model\" src=\"http://www.minecraft-skin-viewer.net/3d.php?layers=true&aa=true&a=0&w=0&wt=0&abg=0&abd=0&ajg=0&ajd=0&ratio=8&format=png&login=$player_name&headonly=false&displayhairs=true&randomness=104\"                          \n                          </div>\n                           \n                            </div>\n                              <a id=\"search-result\">\n                          <div id=\"player-head\">\n</div>\n                          <img id=\"search-result-player_head\" src=\"http://www.minecraft-skin-viewer.net/3d.php?layers=true&aa=true&a=0&w=310&wt=50&abg=330&abd=40&ajg=340&ajd=20&ratio=13&format=png&login=$player_name&headonly=true&displayhairs=false&randomness=396\" height=\"45px\" width=\"45px\">\n                          <div id=\"search-result-player_name\">$player_name</div>\n                          <div id=\"search-result-team_name\">$current_team</div>\n                          <div id=\"search-result-kills\">$kills</div>\n                          <div id=\"search-result-banner\"></div>\n                          </a>\n                                                 ";              echo "$output";          }      }else{          $output = "<div id=\"no-result\">ingen spelare hittad, sök igen...</div>";          echo "$output";      }  }  ?>

this how looks like:

i don't have 10 rep here gyazo link: http://i.gyazo.com/4395819df524124614246612aa2c5bd8.png

the search working want let's click first result , want se more info

this looks when press first result of list: http://i.gyazo.com/b2ab39572c0148b5376beb0c2928e800.png

and how want it. here issue. if click other results in list same variables first result. example if press 3rd result still same popup if press first result.

if change search , click still uses first result variables.

so thing need how can make each result use it's own variables popup/more info div.

try use:

$(document).on('click', '#search-result', function(){     $(this).find("#mydiv").fadein(); });  $(document).on('click', '#close', function(){     $(this).find("#mydiv").fadeout();  }); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -