Hi there everyone,

How can I copy distinct results of a query to a table in a DB?  I have 3 pulldowns, 
the first one selects the category, then the second one gets the holiday type based on 
the category, and the third one gets from countries where category = category AND 
holiday type = holiday type.  The problem is there is almost 30,000 entries which it 
needs to sort through and it takes a few seconds for each pulldown to be calculated, 
is there a better way than the below 

Basically i'm guessing I can grab the results and then insert them into a seperate 
table so that I only save the unique results and so don't have to sort once i've 
created the new table?

Thanks for your help everyone,

Chris


(For the first pulldown):

      <form method="post" action="#form1">
             <form method="post" action="#form1">
        <div align="center"><b><font face="Arial, Helvetica, sans-serif" size="2" 
color="#FFFFFF"> 
          <?$result = mysql_query("select distinct category from search ORDER BY 
category");?>
          <select name="category" onChange="submit()">
            <? if ($category ==""){
  ?>
            <option>Make a Selection</option>
            <?} else {
?>
            <option>Selected >>></option>
            <? }?>
            <? if ($result) 
   { while ($myrow = mysql_fetch_array($result))
      { echo "<OPTION VALUE=\"".$myrow["category"]."\">".
           $myrow["category"]." </OPTION>"; }?>
          </select>
          <? } ?>
          </font></b></div>
      </form>

For the second pulldown:

      <form method="post" action="#form2">
        <div align="center"><b><font face="Arial, Helvetica, sans-serif" size="2" 
color="#FFFFFF"> 
          <?$result = mysql_query("select distinct type from search WHERE category = 
'$category'  ORDER BY type ");?>
          <select name="type" onChange="submit()">
            <? if ($type ==""){
  ?>
            <option>Make a Selection</option>
            <?} else {
?>
            <option><<< Selected >>></option>
            <? }?>
            <?
if ($result) 
   { while ($myrow = mysql_fetch_array($result))
      { echo "<OPTION VALUE=\"".$myrow["type"]."\">".
           $myrow["type"]." </OPTION> "; }?>
          </select>
          <? } ?>
          <input type="hidden" name="category" value="<?=$category?>">
          </font></b></div>
      </form>

For the third pulldown:

     <form method="post" action="#search">
        <div align="center"><b><font face="Arial, Helvetica, sans-serif" size="2" 
color="#FFFFFF"> 
          <?$result = mysql_query("select distinct country from search WHERE category 
= '$category' AND type = '$type' ORDER BY country");?>
          <select name="country" onChange="submit()">
            <? if ($country ==""){
  ?>
            <option>Make a Selection</option>
            <?} else {
?>
            <option><<< Selected >>></option>
            <? }?>
            <?
if ($result) 
   { while ($myrow = mysql_fetch_array($result))
      { echo "<OPTION VALUE=\"".$myrow["country"]."\">".
           $myrow["country"]." </OPTION> "; }?>
          </select>
          <? } ?>
          <input type="hidden" name="type" value="<?=$type?>">
          <input type="hidden" name="category" value="<?=$category?>">
          </font></b></div>
      </form>

Reply via email to