Re: Looking for help with forms/variables and an array!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, June 12, 2007 3:20 am, BSumrall wrote:
> Dreamweaver help me with a good part of this,

No comment...

> A selection box has 4 options, php queries the Mysql database for
> matching
> options.
>
> Then a second options box with another 4 options filters the query
> even
> more.

When the user picks from the first 4, do the second 4 change?

If so, you have to do that in JavaScript, because PHP is long gone
from the picture by the time the use chooses.

> 1 associating options (in drop down box) with a variable

The name="select" part forms an association between the user choice and:
$_POST['select']

> 2 carrying the result set over two the second drop down box

If you want to do this while the user is clicking, it's JavaScript,
not PHP.

> Producing my final result set.
>
> Here are some snippets of where I am at.
>
> First selection box:
>
> <form id="form1" name="form1" method="post" action="">
>                       <label>market
>                         <select name="select">
> 						   <OPTION>option1</OPTION>
> 						   <OPTION>option2</OPTION>
> 						   <OPTION>option3</OPTION>
> 						   <OPTION>option4</OPTION>
> 						</select>
>
>
>
> Second selection box:
>
> <form id="form2" name="form2" method="post" action="">
>                       <label>market
>                         <select name="select">

Use a different name for this one.
Call it "select2" perhaps.

Or name the first one "select[1]" and this one is "select[2]"

$_POST['select'] will then be an array with indexes 1 and 2.

> $query_Recordset1 = "SELECT * FROM lstng_tbl WHERE range = '1'";
>
> The number one is what the first set of just above is what form one is
> supposed to change.
>
> After that, how is the world am I going to do it twice for the second
> part
> of the query?

if (isset($_POST['select']) && isset($_POST['select'][1]) &&
isset($_POST['select'][2])){
  $range1 = (int) S_POST['select'][1];
  $range2 = (int) $_POST['select'][2];
  $query = "SELECT * FROM lstng_tbl WHERE range1 = $range1 and range2
= $range2";
}

Or, perhaps you want:
$query = "SELECT * FROM lstng_tbl WHERE range BETWEEN $range1 and
$range2";

Or...  I dunno what you might want. Could be almost anything.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux