rowCount() . "
"; // print 'colcount=' . $queryres->columnCount() . "
"; $colcount = $queryres->columnCount(); $rowcount = $queryres->rowCount(); print "\n"; print ""; for ($i = 0; $i <= $colcount; $i ++) { $meta = $queryres->getColumnMeta($i); $colname = $meta['name']; print "\n"; } print "\n"; $rownum = 0; while ($rownum < $rowcount) { // FETCH_NUM: fetch as a numeric-indexed array, starting at 0 $row = $queryres->fetch(PDO::FETCH_NUM); print ""; $col = 0; while ($col < count($row)) { print ""; } print "\n"; $rownum++; } print "
"; print $colname; print "
"; if ($row[$col] == NULL) print $nullval; else print ($row[$col]); $col++; print "
\n"; } function connect_pdo($hostname, $username, $password, $database) { try { $dbconn = new PDO("mysql:host=$hostname;dbname=$database", $username, $password); /*** echo a message saying we have connected ***/ //echo 'Connected to database

'; return $dbconn; } catch(PDOException $e) { echo $e->getMessage(); return null; } } /* * simple_query executes a simple prepared query. * In the event of failure it returns a string describing the error; * this can be identified using is_string(). * The PDOStatement object is returned if the query is successful. * One row of the return object is obtained by the $stmt->fetch() method */ function simple_query($db, $query, $queryargs) { $stmt = $db->prepare($query); if ($stmt == FALSE) { $errarray = $db->errorInfo(); // error would live in $db $errmsg = $errarray[2]; $error = "Prepare-statement error for query \"$query\": error is $errmsg"; return $error; } $ret = $stmt->execute($queryargs); // $stmt is the PDOStmt object if ($ret == FALSE) { print("execution of query not successful: \"$query\"

\n"); $errarray = $stmt->errorInfo(); $errmsg = $errarray[2]; $error = "query execution unsuccessful: \"$query\"; error is $errmsg"; return $error; } return $stmt; } /* * $menuname is the name given to the menu itself, that will be used to retrieve * the selected value from $_POST. * $names is an array of strings like ['foo', 'bar', 'quux'], these are used * as the menu choices (both name and value) */ function makeSelectMenu($menuname, $names) { print ""; } function makeSelectMenuString($menuname, $names) { $result = "\n"; return $result; } function makePageButtons () { print <<


END; } ?>