|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Passing parameters from a list box
Hi
I'm struggling. I have created a 2 column table containing a listbox (left) and a map drawn from another page (right). I want to be able to select an item from the list box and the data to be displayed on the right. Here is the code: $sql="SELECT speciesid, common_name FROM species ORDER BY common_name"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["speciesid"]; $co_name=$row["common_name"]; $options.="<OPTION VALUE=\"$id\">".$co_name; } ?> ........... <table width="260" border="2"> <tr> <td></td> <td> <SELECT NAME=common_name> <OPTION VALUE=0>Choose <?=$options?> </SELECT> </td> <td> <?php echo "<img src=latest3.php?s_speciesid=$id&thumbnail=on WIDTH=250 HEIGHT=350>"; ?> </td> </tr> </table> List box works fine but all I get is the last record displayed on the right in the retrieved page and not the record selected from the list. Can anyone guide me please? |
|
#2
|
|||
|
|||
|
you need to open form tags i know exactly what uve dont because ive done it too...just make sure you open form tags and use the select name to put the information into the database....
and example of a form open should look something like this PHP Code:
form name doesnt really matter whats important is the method, which you are posting, and the action or where it goes after theinformation is entered...give it a try let me know what happens |
|
#3
|
|||
|
|||
|
list box parameters
Many thanks Bruski, that's a good start for me but I am having difficulty translating the syntax to my example. Can you be a little more precise? Thanks again.
|
|
#4
|
|||
|
|||
|
i would do it like this
PHP Code:
notice how the form is opened and closed before and after the while statement, because we dont want to open more than one...this should work...also when you try to get the value get the value from PHP Code:
where the two names is what u would call it...give it a try |
|
#5
|
|||
|
|||
|
list box parameters
Hi
I can see where this goes but the problem I can't seem to resolve is holding the selected parameter so that it is used in the other column of the table which displays another page as follows: <img src=latest3.php?s_speciesid=this_is_the_paremeter_ to_hold_from_the_listbox&thumbnail=on WIDTH=250 HEIGHT=350> This where I need to get to. Thanks again - |
|
#6
|
|||
|
|||
|
well use it like this $_POST['parameter'] this will get your parameter everytime u select it....for example you drop down and choose bill...which has a value of 2 the $_POST['parameter'] will get that number and if you were to echo it out it would say 2
|
|
#7
|
|||
|
|||
|
list box parameters
Hi Bruski
Looks like I'll have to give up on this one. Not something I find very palitale I must say! I've struggled with this over the last 24 hrs and have got nowhere. I'll have to tru another way. Thank you for your support and patience. |
|
#8
|
|||
|
|||
|
send me the script and ill have a look at it
|
|
#9
|
|||
|
|||
|
Hi Bruski
Attached script as text file. As I left it. This produces the populated drop down and the php file displayed as an image in the second column. I need to restrict the displayed data in the second column, from the latest3.php page to that from the chosen item in the drop down. Hope that makes some sense. Many thanks for your time |
|
#10
|
|||
|
|||
|
ill take a look at it and do something with it as soon as i can
|
|
#11
|
|||
|
|||
|
hey i just took a glance over your code, if im understanding correctly, you want a picture to appear according to what the user selects. Now if you have a button that sends that data, you will have to click the button and refresh the page with that data, if you had a menu when u click on the item in the menu to automaticallly do this then it would work
|
|
#12
|
|||
|
|||
|
if your just trying to get a picture my suggestion would be to do it like this
<img src=image_<?$variable?>.gif> instead of going to another page and getting it |
|
#13
|
||||
|
||||
|
are you sure its the select box that's giving you the error?
the code you posted in draft.txt looks fine... except i'd put something like: PHP Code:
what's the code inside latest3.php look like? |
|
#14
|
|||
|
|||
|
passin listbox parameters
Hi Guys
Sorry for the delay in getting back. Had a couple of days off. You can see how it works here. http://www.derbyshire-dragonflies.o...testing/map.php This will be available for a couple of days. (ignore the map to the right) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Passing parameters from a list box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|