Solved

Can I pass multiple variables through a list menu in Dreamweaver

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now