Try this
Table : col1 : col2
1. Hotel 1
select name = my_selection
?php
include config.php;
$res = mysql_query(SELECT * FROM tname);
while ($row = mysql_fetch_array($res))
{
$col1 = $row[col1];
$col2 = $row[col2];
option value = \$col1\
savaidis,
Thursday, May 02, 2002, 11:07:18 AM, you wrote:
s I have one table with about 1000 hotels and name or the city they belong.
s I want to run a query to get one row for every city only, to put it in a
s pull down menu in the search form.
s How is that?
Try SELECT DISTINCT city FROM
[snip]
I have one table with about 1000 hotels and name or the city they belong.
I want to run a query to get one row for every city only, to put it in a
pull down menu in the search form.
How is that?
[/snip]
SELECT DISTINCT city
FROM tblFOO
So if you have this table;
It might be faster to instead of getting the list of cities and then in
seperate queries get all hotels for each city, to just sort by city and
fetch all, and in your application check if it has found a next city
already.
Example in php:
$res=mysql_query('select hotel,city from hotels order by
[snip]
It might be faster to instead of getting the list of cities and then in
seperate queries get all hotels for each city, to just sort by city and
fetch all, and in your application check if it has found a next city
already.
[/snip]
Of course, you could use a single crosstab query and get
-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 02, 2002 3:23 PM
To: 'savaidis'; [EMAIL PROTECTED]
Subject: RE: get one name for each row
[snip]
I have one table with about 1000 hotels and name or the city they belong.
I want to run a query to get one row for every city
[snip from mysql list message]
I tried
select distinct Location from hotels1 order by Location
and worked.
But how can I show all fields of the rows?
It doesn't accept any field before distinct and shows every row after
distinct (if I put select distinct Location, Name ... )
[/snip]
Can we see
-hotels.gr
Makis
-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 02, 2002 6:59 PM
To: 'savaidis'; [EMAIL PROTECTED]
Subject: RE: get one name for each row
[snip from mysql list message]
I tried
select distinct Location from hotels1 order