Solved

store selected drop down list value and pass the value to the next pagefor further retrieving purpose

Posted on 2004-08-16
4
196 Views
Last Modified: 2008-02-01
hi,

can anyone know how to store selected drop down list value(values retrieving from oracle)and pass the value to next page for further retrieving purpose.
i oredi finish the function code for showing all the values from the oracle to a drop down list:

function createDropDown($tableName,$fieldName,$inputName,$result){

      $query = ("SELECT DISTINCT ". $fieldName ." FROM ". $tableName);
      ora_parse($result, $query,0);
      ora_exec($result);
      $returnDropDownString = "<select name='".$inputName."'>\n";
    $numcols = ora_numcols($result);
      while (ora_fetch($result)) {
            //for($i=0;$i<$numcols;$i++){
                  $returnDropDownString .= "<option value='".ora_getcolumn($result,0)."'>";
                  $returnDropDownString .= ora_getcolumn($result,0);

                  $returnDropDownString .= "</option>\n";
            
            //}
       }
      $returnDropDownString .= "\n</select>\n";

      return $returnDropDownString;
}

the code oredi successfully pull all the values from specific field from the table.now,i would like to know the way to store the selected value and pass value to next page so that i can continue retrieving the selected value's data.

urgent!!!thx:)
0
Comment
Question by:oywch
4 Comments
 
LVL 25

Accepted Solution

by:
Squinky earned 63 total points
Comment Utility
Assuming that the fragment that this generates is part of a form, you will get a value delivered in $_REQUEST[$inputName] in the script that receives the form submission.
0
 
LVL 4

Assisted Solution

by:adaoss
adaoss earned 62 total points
Comment Utility
Hi

To pass values from a page to another you have yo create a form. I assume you already have one, i also assume that you have defined form's method as POST.

Ex: <form name="form" action="page2.php" method="POST">

Then, in page2.php you just need to call $value = $_POST["$inputName"];
if method is get then $value = $_GET["$inputName"];

if you dont know what is the name of the variable $inputName you can always create a hidden value  to store it:

Your function wil look like:
function createDropDown($tableName,$fieldName,$inputName,$result){

     $query = ("SELECT DISTINCT ". $fieldName ." FROM ". $tableName);
     ora_parse($result, $query,0);
     ora_exec($result);
 
     $returnDropDownString = "<input type='hidden' name='selectname' value='$fieldName'><select name='".$inputName."'>\n";
    $numcols = ora_numcols($result);
     while (ora_fetch($result)) {
          //for($i=0;$i<$numcols;$i++){
               $returnDropDownString .= "<option value='".ora_getcolumn($result,0)."'>";
               $returnDropDownString .= ora_getcolumn($result,0);

               $returnDropDownString .= "</option>\n";
         
          //}
      }
     $returnDropDownString .= "\n</select>\n";

     return $returnDropDownString;
}

and in this case you have to do this way:

$variable = $_POST["selectname"];
$value = $_POST[ $variable ];

Good luck

Adao
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

771 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

11 Experts available now in Live!

Get 1:1 Help Now