Solved

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

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

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

Suggested Solutions

Title # Comments Views Activity
Integrate Office 365 calendar events into WordPress sites 2 52
test if query has no results 2 19
datetime in sql 6 25
Method for submitting dynamically created rows 20 16
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
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 …

911 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

21 Experts available now in Live!

Get 1:1 Help Now