Solved

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

Posted on 2004-08-16
4
204 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 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