Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.37 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5.         <title></title>
  6.     </head>
  7.     <body>
  8.         <?php
  9.         class dbConnect
  10.         {
  11.             private $host;
  12.             private $username;
  13.             private $password;
  14.             private $db_name;
  15.             private $db_link;
  16.             private $db_select;
  17.            
  18.             public function setDB()
  19.             {
  20.                 $this->host = "localhost";
  21.                 $this->username = "root";
  22.                 $this->password = "";
  23.                 $this->db_name = "overviewer";
  24.             }
  25.            
  26.             public function connect()
  27.             {
  28.                 $this->db_link = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());
  29.             }
  30.            
  31.             public function selectTable()
  32.             {
  33.                 $this->db_select = mysql_select_db($this->db_name)or die(mysql_error());
  34.             }
  35.                        
  36.         }
  37.         $obj = new dbConnect();
  38.         $obj->setDB();
  39.         $obj->connect();
  40.         $obj->selectTable();
  41.        
  42.        
  43.        
  44. echo '<h3 style="margin-bottom:5px;">Mitarbeiter, welche an diesem Projekt gearbeitet haben:</h3>';
  45.     $query = "SELECT * FROM user";
  46.     $result = mysql_query($query);
  47.  
  48.     echo '<table  border="1" cellspacing="0" cellpadding="3" width="100%">';
  49.     echo '<tr style="background-color:#58ACFA;">
  50.       <td><b>Benutzername</b></td>
  51.       <td><b>Name</b></td>
  52.       <td><b>Vorname</b></td>
  53.       <td><b>Rechte</b></td>
  54.       <td></td>
  55.       </tr>';
  56.     while($row = mysql_fetch_array($result))
  57.     {
  58.         $u_id = $row['u_id'];
  59.         $s_id = $row['s_id'];
  60.         $u_uname = $row['u_uname'];
  61.         $u_name = $row['u_name'];
  62.         $u_fname = $row['u_fname'];
  63.         $u_right = $row['u_right'];
  64.         $s_start_arr[$count] = $row['s_start'];
  65.         $s_end_arr[$count] = $row['s_end'];
  66.         $count++;
  67.         ?>
  68.  
  69.     <tr>
  70.         <td><?php echo $u_uname; ?></td>
  71.         <td><?php echo $u_name; ?></td>
  72.         <td><?php echo $u_fname; ?></td>
  73.         <td><?php
  74.             if($u_right == 3 )
  75.             {
  76.                 echo "Administrator";
  77.             }
  78.             elseif($u_right == 2)
  79.             {
  80.                 echo "Teamleader";
  81.             }
  82.             elseif($u_right == 1)
  83.             {
  84.                 echo "Mitarbeiter";
  85.             }
  86.             else
  87.             {
  88.                 echo "Nicht spezifiziert";
  89.             }
  90.             ?></td>
  91.         <td>
  92.             <a href="index.php?site=project&view_project&user_project_view=<?php echo $u_id; ?>"><img src="images/icons/view.png" width="16px"alt="edit" border="0" ></a>
  93.         </td>
  94.     </tr>
  95.     <?php
  96.     }
  97.  
  98.  
  99.     //Der geschätze Gesamtumsatz wird berechnet
  100.     $query_sum = "SELECT p_hourly_rate FROM project WHERE p_id = '".$_GET['view_project']."'";
  101.     $result_sum = mysql_query($query_sum);
  102.     $count = mysql_num_rows($result_sum);
  103.  
  104.     while($row_sum = mysql_fetch_array($result_sum))
  105.     {
  106.         $p_hourly_rate = $row_sum['p_hourly_rate'];
  107.     }
  108.  
  109.     if(!empty($s_start_arr))
  110.     {
  111.         $s_res_hours = (array_sum($s_end_arr) - array_sum($s_start_arr)) / 3600;
  112.     }
  113.     $p_total = $p_hourly_rate * $s_res_hours;
  114.     echo '</table>';
  115.     ?>
  116.     </body>
  117. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement