PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > where in select; should be simple
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
where in select; should be simple

Réponse
 
LinkBack Outils de la discussion
Vieux 04/01/2008, 17h48   #1
Jannis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut where in select; should be simple

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
  Réponse avec citation
Vieux 04/01/2008, 17h52   #2
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where in select; should be simple

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.


  Réponse avec citation
Vieux 04/01/2008, 18h41   #3
lark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where in select; should be simple

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.
  Réponse avec citation
Vieux 04/01/2008, 18h42   #4
Jannis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where in select; should be simple

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.
  Réponse avec citation
Vieux 05/01/2008, 10h48   #5
Jannis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where in select; should be simple

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.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h37.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13752 seconds with 13 queries