<html> <title>Pokemon Search</title> <HEAD> <LINK REL="stylesheet" TYPE="text/css" HREF="styles.css" TITLE="Style"> </HEAD> <body> <h1>Zoek naar: <?php echo $_GET["pokemon"]; ?> <p> <?php echo "found: ".$_GET["aantal"]." record"; ?> </h1> <form name="pokemon_form" method="get" action="pconnect.php"> Which Pokemon: <input type="text" name="pokemon"> <input type="hidden" name="aantal" value=<?php echo $aantal?> > <input type="submit" value="Zoek"> </form> <?php require_once('HTML/Table.php'); #mysql_connect("192.168.1.26","root",""); #mysql_connect("localhost","root","mysql"); #mysql_select_db("biosql"); #$db = DBI->connect( 'dbi:mysql:mysql', # 'root', # 'mysql', # ) || die "Database connection not made: $DBI::errstr"; $user = 'root'; $pass = 'biobix'; $host = 'localhost'; $db_name = 'biobix'; // Data Source Name: This is the universal connection string $dsn = "mysql://$user:$pass@$host/$db_name"; require_once ('DB.php'); $db = DB::connect($dsn); $sql_count = "select count(*) from pokemon where English_name like '".$_GET["pokemon"]."%';" ; $sql = "select * from pokemon where English_name like '".$_GET["pokemon"]."%';" ; echo $sql_count; $result2 = $db->query($sql_count); $result = $db->query($sql); $result2->fetchInto($arr_count1,DB_FETCHMODE_ORDERED); $aantal = $arr_count1[0]; $table = new HTML_Table (Array ("border" => "1", "width" => "95%", "align" => "center")); $table->addRow(Array("Header1","Header2")); while ($result->fetchInto($arr,DB_FETCHMODE_ORDERED)) { $table->addRow(Array($arr[1],$arr[2])); }; echo $arr_count1[0]; $table->setColAttributes(0,"align=center"); $table->setColAttributes(1,"align=center"); $row1Style = array("class" => "bg0"); $row2Style = array("class" => "bg1"); $table->setRowAttributes (0, "style = 'background-color: #EEEEEE; color: #000000'"); $table->altRowAttributes (1, $row1Style,$row2Style); $table->display(); #if (PEAR::isError($db)) { //This is an example of what you can do when an error happens. You could also log the error or try to recover from it. # die($db->getMessage().' '.$db->getUserInfo()); #} //DB::connect will return a Pear DB object on success // or a Pear DB Error object on error // You can also set to TRUE the second param // if you want a persistent connection: // $db = DB::connect($dsn, true); //$db = DB::connect($dsn); //$db->setfetchMode(DB_FETCHMODE_ASSOC); //if (PEAR::isError($db)) { //This is an example of what you can do when an error happens. You could also log the error or try to recover from it. // die($db->getMessage().' '.$db->getUserInfo()); //} //$db= OCILogon($user,$pass,$db_name); // With DB::isError you can differentiate between an error or // a valid connection. #if (DB::isError($db)) { // //echo "<b>hierro</b>"; # die ($db->getMessage()); #} ?>