Solved

Can I pass multiple variables through a list menu in Dreamweaver

Posted on 2008-10-07
5
273 Views
Last Modified: 2012-05-05
I have a list menu that has the following choices
1-100
101-200
201-300
etc.,.....

In mySQL statement I need to get those 2 values in my BETWEEN var1
AND var2 condition.

Dreamweaver has the ability to pass a value through the selection, but how do I pass multiple values through the list menu? can I separate them through commas? Brackets?
Any help is appreciated.
-A
0
Comment
Question by:adrake9
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
yessirnosir earned 500 total points
ID: 22666264
Try the approach below:  the ranges can be output from the form as a delimited string and then split into the component parts with the split() function.  eg. in the code below, I just used ranges like you did:  1-100, 101-200, etc.

Note that you could also do something like
<option value="1-100">Any Text String Here</option>
if you want to use one string for the user to see, but actually send your variables as a different string.
<!-- save this document as mypage.htm   -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pass Two Variables from List Menu </title>
</head>
 
<body>
<?php 
$value = $_POST['mydatarange'] ;
$value_split = split("-",$value);
$var1 = $value_split[0];
$var2 = $value_split[1];
?>
<p><?php echo "Var 1 is: ".$var1; ?></p>
<p><?php echo "Var 2 is: ".$var2; ?></p>
<form action="mypage.htm" method="post">
<select name="mydatarange" >
  <option value="#" >Choose a Range</option>
  <option>1-100</option>
  <option>101-200</option>
  <option>201-300</option>
 
</select>
<input type="submit" value="Submit Form">
</form>
</body>
</html>

Open in new window

0
 
LVL 14

Expert Comment

by:yessirnosir
ID: 22666348
probably obvious, but above code may have to be changed to use .php extension; I've got my system setup to interpret .htm with php so I forget about that sometimes.
0
 
LVL 2

Author Closing Comment

by:adrake9
ID: 31504206
If I am using these numbers in a mySQL statement will the values that are split end up as a string or a integer? If there a string my WHERE statement in mySQL would need something numeric to be able to carry out a =, or a <= or a BETWEEN - AND statement?
0
 
LVL 14

Expert Comment

by:yessirnosir
ID: 22668934
re: "will the values that are split end up as a string or a integer"?
Since php is what they call "loosely typed", I think you'll find that you'll be able to use the data as either number or text.  eg. try the code below -- you can do a mathematical operation on var1 and var2 and then immediately do a string operation on them.   When you add the variable to a database, I think the variable type will adjust to whatever the database column type is, i.e. integer, char, etc.   If you find you have any problem with type mismatch, it is possible to force the type, eg. $var1 = (Integer)$var2, see this for more info: http://hudzilla.org/phpwiki/index.php?title=Forcing_a_type_with_type_casting 
$value = $_POST['mydatarange'] ;
$value_split = split("-",$value);
$var1 = $value_split[0];
$var2 = $value_split[1];
$var3 = $var1 + $var2;
$var4 = $var1.$var2;
?>
<p><?php echo "Var 1 is: ".$var1; ?></p>
<p><?php echo "Var 2 is: ".$var2; ?></p>
<p><?php echo "Sum is: ".$var3; ?></p>
<p><?php echo "Concat is: ".$var4; ?></p>

Open in new window

0
 
LVL 2

Author Comment

by:adrake9
ID: 22669326
Thanks for the follow up. Very clear explanation. I did get it to work perfectly. I'm just a newbie, but this is kinda like art. Give a person the canvas and the brush, and you can create just about anything! Brilliant
-a
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question