Page 1 of 1

DB driven menu

Posted: Mon Oct 14, 2002 7:31 am
by pbangsoe
Could anybody help with code or link to a Oracle/PHP driven dropdown menu.

Very hard to find - so please help !

:P

Posted: Mon Oct 14, 2002 10:22 am
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

Posted: Tue Oct 15, 2002 7:41 am
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".