//If you have a working PHPLIB installed, you might want to enable all
// of the session-related lines in this file, as that will make several
// additional features possible (such as variable number of conditions and
// the next/prev buttons)
//page_open( array("sess" => "Poe_Session" ));
require("c_timer.inc");
$timer = new c_Timer;
$timer->start();
// do nothing
function add_filter_objects( $f )
{
}
function getSelectQuery( $name )
{
switch ($name )
{
case "s_classname":
$t1 = new SQL_Cond( "enzclass", "classname" );
return new SQL_Select( $t1 );
case "s_funcname":
$t1 = new SQL_Cond( "enzclass", "enzclassid", "=",
"enzclass_enzfunc", "enzclassid" );
$t2 = new SQL_Cond( "enzclass_enzfunc", "enzfuncid", '=',
"enzfunc", "enzfuncid" );
$t3 = new SQL_Cond( "enzfunc", "funcname" );
return new SQL_Select( $t1->sand( $t2->sand($t3) ) );
case "s_varname":
$t1 = new SQL_Cond( "enzclass", "enzclassid", "=",
"enzclass_enzvar", "enzclassid" );
$t2 = new SQL_Cond( "enzclass_enzvar", "enzvarid", '=',
"enzvar", "enzvarid" );
$t3 = new SQL_Cond( "enzvar", "name" );
return new SQL_Select( $t1->sand( $t2->sand( $t3 ) ) );
}
}
include( "../../EnzymeTemplates/display_student.inc" );
include( "enz_objects.inc" );
require( "enz_db.inc" );
require "SQL_Select.inc";
require "oohforms.inc";
require "sqlforms.inc";
require "special_menu.inc";
print "";
$default_sql = new SQL_Select( new SQL_Cond( "enzclass","enzclassid",">","0"));
$default_sql->what_to_select = "enzclass.enzclassid";
//strings that begin with s_ are names of SQL_Select objects and are
//defined in setup_queries.inc
$option = array( "s_classname" => "Class",
"s_funcname" => "Function",
"s_varname" => "Variable"
);
$f = new sql_form;
$f->add_element( array( type => filter,
name => "sel",
options => $option,
extrahtml => "onChange = 'UpdateMenu( this.form, this)'",
addblank =>'[ Select Your Search Criteria ]',
size => 1,
sql_func => "getSelectQuery",
op => "=",
target_from => "suggest"
) );
$f->add_element( array( type => select,
name => "suggest",
options => suggestList( $GLOBALS["sel"] ),
// extrahtml => "onChange = 'PutText(this)'",
addblank => ' [ Empty Field ] '
));
$f->add_element( array( type => "submit",
name => "submit",
value => "Submit" ) );
$f->load_defaults();
$f->start( "sql_form",
"GET",
is_object($sess) ? $sess->self_url() : $GLOBALS[PHP_SELF] );
$f->show_element( "sel" );
print( "
" );
$f->show_element( "suggest" );
print( "
" );
$f->show_element( "submit" );
$f->finish();
$Sql = $f->get_sql( $default_sql );
if (isset( $sel ) && $Sql)
{
$db = new DB_Enz;
printf( "\nTo get the actual results, I would query:
%s
\n",
$sql_string = $Sql->toString() );
$result = $db->query( $sql_string );
$query_results = $db->num_rows();
while( $db->next_record() )
{
$sid = $db->f( "enzclassid" );
$stud = new Enzclass( $sid );
$stud->printShort();
$count++;
}
}
$timer->stop();
echo "Time elapsed: ".$timer->elapsed()."
";
//page_close();
?>