Solved

Can I pass multiple variables through a list menu in Dreamweaver

Posted on 2008-10-07
5
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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