Solved

Can I pass multiple variables through a list menu in Dreamweaver

Posted on 2008-10-07
5
281 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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 …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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