Solved

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

Posted on 2004-08-16
4
210 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
[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
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: 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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

724 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