General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 6th, 2003, 04:00 AM
PJW PJW is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 6 PJW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old December 6th, 2003, 07:44 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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="post\" action=\"?page=forums&x=forumAdd\" method=\"POST\"> 


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

Reply With Quote
  #3  
Old December 6th, 2003, 10:14 AM
PJW PJW is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 6 PJW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old December 6th, 2003, 11:14 AM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
i would do it like this

PHP Code:
echo "<form name=\"post\" action=\"to where ever" method="POST\"><br>";
            
$query "SELECT speciesid, common_name FROM species ORDER BY common_name";
            
$result mysql_query ($query);
            echo 
" <select name=\"NAME\">";
                while (
$row=mysql_fetch_array($result)) {
                     
$id=$row["speciesid"];
$co_name=$row["common_name"]; 
                    echo 
"<option value=\"$id\">$co_name</option>";
                }
            echo 
"</select>";

        echo 
"<input type=\"submit\" name=\"submit\" class=\"submit\" value=\"Add Forum\">";
        echo 
"</form>"


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:
 $_POST['NAME']; 


where the two names is what u would call it...give it a try

Reply With Quote
  #5  
Old December 6th, 2003, 01:11 PM
PJW PJW is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 6 PJW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 -

Reply With Quote
  #6  
Old December 6th, 2003, 01:47 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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

Reply With Quote
  #7  
Old December 8th, 2003, 02:35 AM
PJW PJW is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 6 PJW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #8  
Old December 8th, 2003, 05:20 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
send me the script and ill have a look at it

Reply With Quote
  #9  
Old December 9th, 2003, 02:04 PM
PJW PJW is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 6 PJW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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
Attached Files
File Type: txt draft.txt (1,012 Bytes, 349 views)

Reply With Quote
  #10  
Old December 9th, 2003, 08:13 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
ill take a look at it and do something with it as soon as i can

Reply With Quote
  #11  
Old December 9th, 2003, 08:16 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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

Reply With Quote
  #12  
Old December 9th, 2003, 08:17 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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

Reply With Quote
  #13  
Old December 9th, 2003, 10:47 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
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:
if ($_GET['id'])
    print 
"<img src=\"latest3.php?s_speciesid=$id&thumbnail=on\" WIDTH=250 HEIGHT=350>"


what's the code inside latest3.php look like?

Reply With Quote
  #14  
Old December 14th, 2003, 03:45 AM
PJW PJW is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 6 PJW User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Passing parameters from a list box


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |