php - Should I generate my database query dynamically when the selected option changes? -


i'm generating select option mysql db. on second query i'm displaying list same db. going use javascript match first select second one, wondering if better instead of doing make new query every time selected option changes. ideas? has come across this, , if so, performing better?

include("conexion.php");  $result = mysqli_query($conn,"select * `user_list` `user_id`=$oreo ,  `visibility` =  '0' order `item_num` desc "); $result2 = mysqli_query($conn,"select distinct(`group`) `user_list` `user_id`=$oreo ,  `visibility` =  '0'");  echo "<div> <select id='groopy' onchange='selectivo();'>";  while($row = mysqli_fetch_array($result2)) {     $group_name = $row['group'];     echo "<option>".$group_name."</option>"; }  echo "</select></div>"; echo "<ul id='groopy'>";  while($row = mysqli_fetch_array($result)) {       $group_name = $row['group'];       $item_num = $row['item_num'];       $tit_sup = $row['tit_sup'];       $url = $row['url'];        echo "<li alt='".$group_name."'>".$tit_sup."</li>"; }  echo " </ul>"; 

this how i'm doing now, don't know why don't (it's not giving problems i'm guessing when there lot of content slow everything).

if understand correctly, looking solution scale big number of groups/users without impact on performance.

my ideas are:

  • with reasonable amount of data current solution responsible one, have @ user's side, , have filter list on selected group
  • as database grows, rewrite bit, , load users selected group, , achieved in 2 ways:
    • the whole page reloads on selection-change - keeping functionality working browsers disabled javascript, i'd go next
    • first show empty list - or default 1 -, , load userlist ajax when selection changes; idea can taken 1 step further, in cache loaded userlists, , fill <ul> cache

for better , more precise opinion know when, how , intend use group-selection , userlist, of now, see above mentioned possibilities available.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -