Solved

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

Posted on 2004-08-16
4
205 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:
Marcus Bointon earned 63 total points
ID: 11809358
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
ID: 11809794
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 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