|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
For searching houses I want to make a form with two options: name of
street and house number. I have a table of names of street in a town each with its id number called street_id. First the visitor should choose the street from an option list and then a house number from the next option list. This second option list should only contain numbers that are present in the street chosen. The street option list is OK. The output is the id number. Then follows: $streetnr = $_POST['street_id'].There is another table (called ITEMS) with the items sought after with the fields item_id, street_id, house_number. I want to have item_id as output, to use it in other querries. I guess the second option list should be got by $sql ='SELECT item_id, street_nr, house_number FROM items WHERE street_nr = $streetnr'; I do something wrong as this gives no result. It does when I give in a number instead of $streetnr. I'm sure I overlook something very simple, but somehow I don't see what I do wrong. Any hint is appreciated. Jannis |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Jannis wrote:
> For searching houses I want to make a form with two options: name of > street and house number. I have a table of names of street in a town > each with its id number called street_id. First the visitor should > choose the street from an option list and then a house number from the > next option list. This second option list should only contain numbers > that are present in the street chosen. > The street option list is OK. The output is the id number. Then > follows: $streetnr = $_POST['street_id'].There is another table > (called ITEMS) with the items sought after with the fields item_id, > street_id, house_number. I want to have item_id as output, to use it > in other querries. > I guess the second option list should be got by > $sql ='SELECT item_id, street_nr, house_number FROM items WHERE > street_nr = $streetnr'; > > I do something wrong as this gives no result. It does when I give in a > number instead of $streetnr. > > I'm sure I overlook something very simple, but somehow I don't see > what I do wrong. > Any hint is appreciated. > Jannis Try: $sql ="SELECT item_id, street_nr, house_number FROM items WHERE street_nr = $streetnr"; instead. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Paul Lautman wrote:
> Jannis wrote: >> For searching houses I want to make a form with two options: name of >> street and house number. I have a table of names of street in a town >> each with its id number called street_id. First the visitor should >> choose the street from an option list and then a house number from the >> next option list. This second option list should only contain numbers >> that are present in the street chosen. >> The street option list is OK. The output is the id number. Then >> follows: $streetnr = $_POST['street_id'].There is another table >> (called ITEMS) with the items sought after with the fields item_id, >> street_id, house_number. I want to have item_id as output, to use it >> in other querries. >> I guess the second option list should be got by >> $sql ='SELECT item_id, street_nr, house_number FROM items WHERE >> street_nr = $streetnr'; >> >> I do something wrong as this gives no result. It does when I give in a >> number instead of $streetnr. >> >> I'm sure I overlook something very simple, but somehow I don't see >> what I do wrong. >> Any hint is appreciated. >> Jannis > > Try: > > $sql ="SELECT item_id, street_nr, house_number FROM items WHERE > street_nr = $streetnr"; > > instead. > > this won't work if #streetnr is varchar. if not, it's fine. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Fri, 4 Jan 2008 16:52:11 -0000 wrote "Paul Lautman"
<paul.lautman@btinternet.com>: >Jannis wrote: >> For searching houses I want to make a form with two options: name of >> street and house number. I have a table of names of street in a town >> each with its id number called street_id. First the visitor should >> choose the street from an option list and then a house number from the >> next option list. This second option list should only contain numbers >> that are present in the street chosen. >> The street option list is OK. The output is the id number. Then >> follows: $streetnr = $_POST['street_id'].There is another table >> (called ITEMS) with the items sought after with the fields item_id, >> street_id, house_number. I want to have item_id as output, to use it >> in other querries. >> I guess the second option list should be got by >> $sql ='SELECT item_id, street_nr, house_number FROM items WHERE >> street_nr = $streetnr'; >> >> I do something wrong as this gives no result. It does when I give in a >> number instead of $streetnr. >> >> I'm sure I overlook something very simple, but somehow I don't see >> what I do wrong. >> Any hint is appreciated. >> Jannis > >Try: > >$sql ="SELECT item_id, street_nr, house_number FROM items WHERE >street_nr = $streetnr"; > >instead. > Thank you. I KNEW it was simple. Feel a bit stupid now not having thought about that. Thank you very much. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Fri, 04 Jan 2008 17:41:26 GMT wrote lark <hamzee@sbcglobal.net>:
>Paul Lautman wrote: >> Jannis wrote: >>> For searching houses I want to make a form with two options: name of >>> street and house number. I have a table of names of street in a town >>> each with its id number called street_id. First the visitor should >>> choose the street from an option list and then a house number from the >>> next option list. This second option list should only contain numbers >>> that are present in the street chosen. >>> The street option list is OK. The output is the id number. Then >>> follows: $streetnr = $_POST['street_id'].There is another table >>> (called ITEMS) with the items sought after with the fields item_id, >>> street_id, house_number. I want to have item_id as output, to use it >>> in other querries. >>> I guess the second option list should be got by >>> $sql ='SELECT item_id, street_nr, house_number FROM items WHERE >>> street_nr = $streetnr'; >>> >>> I do something wrong as this gives no result. It does when I give in a >>> number instead of $streetnr. >>> >>> I'm sure I overlook something very simple, but somehow I don't see >>> what I do wrong. >>> Any hint is appreciated. >>> Jannis >> >> Try: >> >> $sql ="SELECT item_id, street_nr, house_number FROM items WHERE >> street_nr = $streetnr"; >> >> instead. >> >> >this won't work if #streetnr is varchar. if not, it's fine. That I saw. I applied settype. |
|
![]() |
| Outils de la discussion | |
|
|