[PHP-DB] Copy distinct results to new table

2002-03-20 Thread Chris Payne

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=centerbfont face=Arial, Helvetica, sans-serif size=2 
color=#FF 
  ?$result = mysql_query(select distinct category from search ORDER BY 
category);?
  select name=category onChange=submit()
? if ($category ==){
  ?
optionMake a Selection/option
?} else {
?
optionSelected /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=centerbfont face=Arial, Helvetica, sans-serif size=2 
color=#FF 
  ?$result = mysql_query(select distinct type from search WHERE category = 
'$category'  ORDER BY type );?
  select name=type onChange=submit()
? if ($type ==){
  ?
optionMake 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=centerbfont face=Arial, Helvetica, sans-serif size=2 
color=#FF 
  ?$result = mysql_query(select distinct country from search WHERE category 
= '$category' AND type = '$type' ORDER BY country);?
  select name=country onChange=submit()
? if ($country ==){
  ?
optionMake 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



[PHP-DB] Copy distinct results to new table solved

2002-03-20 Thread Chris Payne

Hi there everyone,

Just to let you all know I solved the problem I was having earlier - it's probably not 
the most elegant solution but hey, it works and it's very fast so I can't complain :-)

Thanks to everyone in this group for your help on everything i've asked in the past 
(And will probably ask in the future :-)

Chris