Re: SQL query seach + rearranging results
От | Richard Huxton |
---|---|
Тема | Re: SQL query seach + rearranging results |
Дата | |
Msg-id | 200402172026.41114.dev@archonet.com обсуждение исходный текст |
Ответ на | SQL query seach + rearranging results ("lowdog" <lowdog@axelero.hu>) |
Список | pgsql-sql |
On Monday 16 February 2004 16:07, lowdog wrote: > hey guys! > > I need your help in writing a php name-day searcher script. Actually, you probably want a mysql list - this is a PostgreSQL list. However, from what I can understand of your problem I think the easiest solution for you might be to order the results by name (nevek table?) and then loop through building a results list while the name remains the same. Something like: $current_name = ''; while (/* fetch next row */) { if ($row['name']==$current_name) { /* add next "day" to output list */ } else { /* displayoutput list if anything there */ $current_name = $row['name']; $output_list = array(); $output_list[] = $row['day'];} } /* on exiting loop, check if there is a final row to display */ Hope that's of some use. PS - indenting your SQL cleanly on multiple lines will save you time in the future - trust me on this. PPS - localization (the accented characters you are having problems with) is a difficult issue, especially on the web where client/page/database encoding can all interact. PPPS - if you port your application to PostgreSQL, you've found the right list for SQL questions. We also have a PHP list and a novice list if you're just starting. Good luck -- Richard Huxton Archonet Ltd
В списке pgsql-sql по дате отправления: