insert into log_book_id values (logid.nextval, TO_DATE('08/12/1973','MM/dd/YYYY'),'C150','N5787G',1,1.8);
insert into log_book_id values (logid.nextval, TO_DATE('08/17/1973','MM/dd/YYYY'),'C150','N5787G',3,1.5);
insert into log_book_id values (logid.nextval, TO_DATE('08/26/1973','MM/dd/YYYY'),'C150','N5787G',10,1.8);
insert into log_book_id values (logid.nextval, TO_DATE('09/01/1973','MM/dd/YYYY'),'C150','N5293S',9,1.7);
*/
//construct a global variable for the form profile
$fields = array("fdate", "actype", "acid", "nlandings", "nhours");
function displayDeleteForm(){
//get $fields into the function namespace
global $fields;
global $connection;
/* Create and execute query. */
// Loop through each row, outputting the actype and name
echo <<
Pilots Logbook entries stored in Oracle Relational Database
under Redhat Fedora 9 Linux
HTML;
} //close function
// ............................................................ ..... function timeInType()
//
function timeInType()
{
global $connection;
$query = "select actype,sum(nhours) from log_book_id group by actype";
$statement = oci_parse ($connection, $query);
oci_execute ($statement);
// Loop through each row, outputting the actype and name
echo <<
Total Hours =$sum
HTML;
} // while
echo <<
HTML;
}
// ............................................................ ..... function deleteRecords()
//
function deleteRecords()
{
global $connection;
// Loop through each log_book_id with an enabled checkbox
if (!isset($_POST['checkbox'])){
displayDeleteForm();
return true;
}
//else
foreach($_POST['checkbox'] as $key=>$val){
$toDelete[] = $key;
}
//expand the array for an IN query
$where = implode(',', $toDelete);
$query = "DELETE FROM log_book_id WHERE log_id IN ($where)";
$result = oci_parse($connection, $query);
$r = oci_execute($result);
// Commit transaction
$committed = oci_commit($connection);
// Test whether commit was successful. If error occurred, return error message
if (!$committed) {
$error = oci_error($connection);
echo 'Commit failed. Oracle reports: ' . $error['message'];
}
// Should have one affected row
if ((oci_num_rows($result)== 0) ) {
echo "
There was a problem deleting some of the selected items.
".oci_error().'
';
// exit();
} else {
echo "
The selected items were successfully deleted.
";
}
//direct the user back to the delete form
displayDeleteForm();
} //end function
function insertRecord()
{
// global $rowInsert;
global $connection;
global $dFields;
// Retrieve the posted log book information.
global $fields;
// $messages = array();
//add some very crude validation
foreach ($fields as $field){
if (empty($_POST[$field])){
$messages[] = "You must complete the field $field \r\n";
} else {
// $dFields[$field] = mysql_real_escape_string(trim($_POST[$field]));
$dFields[$field] = trim($_POST[$field]);
}
}
if (count($messages)>0) {
displayEntryForm($messages, $dFields);
exit();
}
//end validation
function showRecord() {
// show selected record
global $fields;
global $dFields;
global $connection;
global $rowInsert;
// Loop through each log_book_id with an enabled checkbox
if (!isset($_POST['checkbox'])){
displayDeleteForm();
return true;
}
//else
foreach($_POST['checkbox'] as $key=>$val){
$toDelete[] = $key;
}
// errors
//get log_book_id table information
$user = "select * from log_book_id where log_id = $toDelete[0]";
$_SESSION['rowInsert'] = $rowInsert;
// setcookie('row_insert',$rowInsert)
//note that we do not rely on the checkbox value as not all browsers submit it
//instead we rely on the name of the checkbox.
// insert the row information in the entry form
global $fields;
//end validation
displayEntryForm();
}
//.......................................................... .................function displayEntryForm()
function displayEntryForm($errorMessages=null, $dFields=null){
if (!empty($errorMessages)){
echo "
".implode('
', $errorMessages) . "
";
}
global $dFields;
//sort out field values
global $fields;
foreach ($fields as $field){
$fieldx = strtoupper($field);
if (isset($dFields[$field])){
${$field} = $dFields[$field];
} else {
${$field} = '';
}
}
// print_r($dFields);
echo <<
HTML;
} //end display function
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php