Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: =?iso-8859-1?Q?RE:_=5Bpro=5Fphp=5D_How_cant=B4_read_the_names_and_values_?=---=?iso-8859-1?Q?off_a_combo-box?=


Message #1 by "Nikolai Devereaux" <yomama@u...> on Wed, 20 Jun 2001 12:06:04 -0700
Que pasa,

Lo siento, pero mi Espanol no esta tan bueno. =)

Lo que yo no comprendo es si quieres solamente un numero, o si quieres la
nombre de la ciudad y el numero tambien.  Hay un numero distinto para cada
ciudad?  Estas usiendo una database?

Si cada ciudad tiene un numero distinto, yo pienso que es mejor si pases
solamente el numero con la forma.

<form method="post" action="http://www.name.com/page.php">
  <select name="cities">
    <option value="1">San Diego</option>
    <option value="2">Athens</option>
    <option value="3">Buenos Aires</option>
  </select>
</form>

Si estas usando una database, puedes usar PHP para ... como se dice... query
el database para todos las ciudades y numeros, y cree la forma en un
while-loop.

<form ...>
  <select name="city">
<?php
    $resultset = mysql_query("SELECT num, name FROM cities");

    while($nextCity = mysql_fetch_assoc($resultset))
    {
        echo "<option value='" . $nextCity[num] . "'>" . $nextCity[name] .
"</option>\n";
    }
?>
  </select>
</form>

Entonces, en "page.php", donde la forma envia la data, puedes usar el numero
($city) para query el database otra vez y sacar el nombre de la ciudad.

Buena suerte,

Nik

----- just in case... -----

What's happening,

I'm sorry, but my spanish isn't that great. =)

What I don't understand is whether you want just a number, or if you want
the name of the city and the number also.  Is there a distinct number for
each city?  Are you using a database?

If each city has it's own number, I think that it'd be better to just pass
the number with the form.

-- code --

If you're using a database, you can use PHP to query the database for all
the cities and numbers, and create the form in a while loop.

-- code --

Then, in page.php, where the form sends the data, you can use the number
($city) to query the database again and get the name of the city.

Good luck,

Nik

> -----Original Message-----
> From: Julio Oliveira [mailto:oliveira_julio@y...]
> Sent: Tuesday, June 19, 2001 7:02 PM
> To: professional php
> Subject: [pro_php] How cantī read the names and values off a combo-box
>
>
> Sorry by my english
>
> I'm doing a web page, with combo-box off same data.
>
> I need to know wich record the client get, how to take
> the value and name off the selection see that.
>
> Como-box  at the browser
>
> City         Buenos Aires
>              Capital        --- >  they take this
>              Cordoba
>
> I need the name, and a hiden value that is a number
> off city perhaps  15.-
>
> Thanks to all sorry by my english
>
> Julio Oliveira - Buenos Aires Argentina.


  Return to Index