DB driven menu

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pbangsoe
Forum Newbie
Posts: 4
Joined: Wed Oct 02, 2002 5:55 am
Location: Copenhagen, Denmark

DB driven menu

Post by pbangsoe »

Could anybody help with code or link to a Oracle/PHP driven dropdown menu.

Very hard to find - so please help !

:P
kamal
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:35 am
Location: Rome, Italy

Post by kamal »

For dropdown menu you mean a form with a select tag?
Something like the one under the posts here?

"Display posts from previous:
All Posts |V|
1 Day
7 Days ...etc "


If you mean that maybe you can try this:

Code: Select all

<?php
$conn = OCILogon($_POSTї"user"],$_POSTї"passwd"],$_POSTї"conn_str"]);

$stmt = OCIParse($conn, "select * from cat");

OCIExecute($stmt);

$nrows = OCIFetchStatement($stmt,$results);
if ( $nrows > 0 ) {
   print "<FORM action=proc.php method="post">\n";
   print "<SELECT>\n";
   while ( list( $key, $val ) = each( $results ) ) {
   for ( $i = 0; $i < $nrows; $i++ ) {
      reset($results);
      while ( $column = each($results) ) {   
         $data = $columnї'value'];
         print "<OPTION>$dataї$i]</OPTION>\n";
      }
   }
}
   print "</SELECT>\n";
   print "</FORM>\n";
}
else {
   echo "<BR>This schema hasn't any cat object.\n";
}

OCIFreeStatement($stmt);
OCILogoff($conn);

?>
This is just a modification of a script I found on the php manual.
This script takes his input from another form... ($_POST).
I hope this helps.
Bye
kamal
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:35 am
Location: Rome, Italy

Post by kamal »

Sorry, there's an error. You have to change the query "select * from cat".
The select must contain only one field, for example:
"select table_name from cat".
Post Reply