|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hey all,
I have a sort of problem. I have a script that searches for airline routes based on departure and destination. The way its set is this: I have 4 steps. The first step shows a search form to search for either depature airport name or code. Then the script does some manipulating and shows the second step, this is where I have some problems. The script searches through the mysql table for all destinations associated with the selected departure, but sometimes there are multiple flights that go to the same place at different times (for example, Chicago to Detroit, there are something like 6 of them), so when the select menu comes up, it has 6 Detroits, 4 New Yorks, etc. How can I query just to pick up uniques? This way the menu will have one detroit and one new york, then at the last step I can show all of the flights that are Chicago to Detroit. Thanks |
|
#2
|
||||
|
||||
|
You could do something like an inline search, search what you already have saved in your combobox for the next item, if it's found then skip to the next item, and search over, otherwise add it to the list..
example pseudocode: Quote:
Hope this helps ![]() Last edited by nicat23 : July 15th, 2003 at 03:11 PM. |
|
#3
|
|||
|
|||
|
yep, that helps a lot, thanks!
![]() |
|
#4
|
||||
|
||||
|
No worries... and I forgot one more thing
Step 8. When you have all of the entries gathered, loop through and add them to a dropdown ![]() Glad to have been able to help |
|
#5
|
|||
|
|||
|
One more question. Instead of doing nested loops and multiple arrays, could I add all of the values from the query to an array, then do an array_unique() on it, and loop through it to add it to the select?
|
|
#6
|
||||
|
||||
|
possibly but I'm not very sure... Haven't tried using array_unique... let me look into it then I'll post again
![]() |
|
#7
|
|||
|
|||
|
Actually, the array_unique does work, if you manipulate it a bit, I found a function on the php.net website that will do the unique strip as well as redo the keys. Here is the function and my final code:
PHP Code:
PHP Code:
That worked fine Last edited by PFerrara : July 15th, 2003 at 04:31 PM. |
|
#8
|
||||
|
||||
|
Sweet
you taught me something new... Thanks!! |
|
#9
|
|||
|
|||
|
Another even easier way to get back uniques is to SELECT DISTINCT in the sql query, instead of just SELECT
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Quering for Uniques, question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|