Untitled Document
Dr Danny Kopec & Colleagues Publications
Home
require_once('heather.php');
function add_pub ( $ID, $Ptitle, $category, $date, $location, $status,$pubBy, $keyw ){
$today = date("F j, Y, g:i a");
$value = "INSERT INTO PUB_INFO VALUES ( '$ID', '$Ptitle', '$category', '$date', '$location', '$status', '$pubBy','$keyw', '$today')";
if (! mysql_query($value, get_conn())){
return false;
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
function add_author ( $ID, $title, $FName, $LName){
$temp = $title." ".$FName." ".$LName;
$value = "INSERT INTO PUB_AUTHOR VALUES ('$ID', '$title', '$FName', '$LName', '$temp')";
if (! mysql_query($value, get_conn())){
return false;
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
function delete_pub($ID){
$pub = "DELETE FROM PUB_INFO WHERE PUBLICATION_ID = '$ID'";
if (! mysql_query( $pub, get_conn())){
return false;
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
function delete_author($ID, $FName, $LName){
$pub = "DELETE FROM PUB_AUTHOR WHERE PUBLICATION_ID = '$ID' and f_name = '$FName' and l_name = '$LName'";
if (! mysql_query( $pub, get_conn())){
return false;
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
function delete_authors($ID){
$pub = "DELETE FROM PUB_AUTHOR WHERE PUBLICATION_ID = '$ID'";
if (! mysql_query( $pub, get_conn())){
return false;
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
function get_pub($ID){
$query = "SELECT * FROM PUB_INFO WHERE PUBLICATION_ID = '$ID'";
$result = mysql_query($query, get_conn());
$check = 0;
if (!is_resource($result)){
print("Unable to select from database");
}
$check = mysql_num_rows($result);
if( $check > 0){
$pub = mysql_fetch_array($result);
return $pub;
}
else{
return false;
}
}
/*---------------------------------------------------------------------------------------------------------------------------------------*/
function get_author($ID, $FName, $LName){
$query = "SELECT * FROM PUB_AUTHOR WHERE PUBLICATION_ID = '$ID' and l_name = '$LName' and f_name = '$FName'";
$result = mysql_query($query, get_conn());
$check = 0;
if (!is_resource($result)){
print("Unable to select from database");
}
$check = mysql_num_rows($result);
if( $check > 0){
$pub = mysql_fetch_array($result);
return $pub;
}
else{
return false;
}
}
/*------------------------------------------------------------------------------------------------------------------------------------*/
function get_authors($ID){
$query = "SELECT * FROM PUB_AUTHOR WHERE PUBLICATION_ID = '$ID'";
$result = mysql_query($query, get_conn());
$check = 0;
if (!is_resource($result)){
print("Unable to select from database");
}
$check = mysql_num_rows($result);
if( $check > 0){
$pub = mysql_fetch_array($result);
return $pub;
}
else{
return false;
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
function print_pub($pub_id ){
$query = "SELECT * FROM PUB_INFO WHERE PUBLICATION_ID = '$pub_id'";
$result = mysql_query($query, get_conn());
$check = mysql_num_rows($result);
if( $check > 0){
while ($i < $check) {
$id=mysql_result($result,$i,"PUBLICATION_ID");
$modified=mysql_result($result,$i,"DATE_MODIFIED");
print "Publication ID: " .$id. " " . "
Last Modified:". $modified."
";
$query1 = "SELECT * FROM PUB_AUTHOR WHERE PUBLICATION_ID = '$id'";
$result1 = mysql_query($query1, get_conn());
$check1 = mysql_num_rows($result1);
print "(";
$i1 = 0;
while ($i1 < $check1) {
$atitle=mysql_result($result1,$i1,"title");
$fname=mysql_result($result1,$i1,"f_name");
$lname=mysql_result($result1,$i1,"l_name");
print $atitle." ".$fname." ".$lname.", "." ";
$i1++;
} print ")";
$title=mysql_result($result,$i,"PUB_TITLE");
$category=mysql_result($result,$i,"CATEGORY");
$location=mysql_result($result,$i,"LOCATION");
$pubBy=mysql_result($result,$i,"PUB_BY");
$status=mysql_result($result,$i,"STATUS");
$date=mysql_result($result,$i,"DATE_PUB");
print ' "'.$title.'," '.$pubBy.','.' '.$location.", " .$date;
$i++;
}
}
else{
print("Table is empty");
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
function view_pub(){
$query = "SELECT * FROM PUB_INFO";
$result = mysql_query($query, get_conn());
$check = mysql_num_rows($result);
if( $check > 0){
while ($i < $check) {
$id=mysql_result($result,$i,"PUBLICATION_ID");
$temp = "./Publications/";
if (!file_exists($temp.$id)){
print ("Publication file in missing from the 'Publications' folder.
");
}
$modified=mysql_result($result,$i,"DATE_MODIFIED");
print "Publication ID: " .$id. " " . "
Last Modified:". $modified."
";
$query1 = "SELECT * FROM PUB_AUTHOR WHERE PUBLICATION_ID = '$id'";
$result1 = mysql_query($query1, get_conn());
$check1 = mysql_num_rows($result1);
$i1 = 0;
print "(";
while ($i1 < $check1) {
$atitle=mysql_result($result1,$i1,"title");
$fname=mysql_result($result1,$i1,"f_name");
$lname=mysql_result($result1,$i1,"l_name");
print $atitle ." ".$fname." ". $lname.",";
$i1++;
} print ")";
$title=mysql_result($result,$i,"PUB_TITLE");
$category=mysql_result($result,$i,"CATEGORY");
$location=mysql_result($result,$i,"LOCATION");
$pubBy=mysql_result($result,$i,"PUB_BY");
$status=mysql_result($result,$i,"STATUS");
$date=mysql_result($result,$i,"DATE_PUB");
print ' "'.$title.'", '.$pubBy.','.' '.$location.", " .$date ."
";
$i++;
}
}
else{
print("Table is empty");
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
function print_author($pub_id ){
$query = "SELECT * FROM PUB_AUTHOR WHERE PUBLICATION_ID = '$pub_id'";
$result = mysql_query($query, get_conn());
$check = mysql_num_rows($result);
if( $check > 0){
while ($i < $check) {
$atitle=mysql_result($result,$i,"title");
$fname=mysql_result($result,$i,"f_name");
$lname=mysql_result($result,$i,"l_name");
print "
"."$atitle"." "."$fname"." "."$lname";
$i++;
}
}
else{
print("Table is empty");
}
}
require_once('footer.php');
?>