Guest User

Untitled

a guest
Jan 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. <?php
  2. $servername = "xxxxxx";
  3. $username = "xxxxx";
  4. $password = "";
  5. $db = "xxxxx";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $db);
  9.  
  10. // Check connection
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14. echo "Connected successfully";
  15.  
  16. $mysqli = new mysqli("xxxxx", "xxxx", "", "xxxxx");
  17.  
  18. /* comprueba la conexión */
  19. if (mysqli_connect_errno()) {
  20. printf("Connect failed: %sn", mysqli_connect_error());
  21. exit();
  22. }
  23.  
  24.  
  25. /* devuelve el nombre de la base de datos actualmente seleccionada */
  26. if ($result = $mysqli->query("SELECT DATABASE(chat)")) {
  27. $row = $result->fetch_row();
  28. printf("Default database is %s.n", $row[0]);
  29. $result->close();
  30. }
  31. /* cambia de test bd a world bd */
  32. $mysqli->select_db("xxxx");
  33. /* devuelve el nombre de la base de datos actualmente seleccionadae */
  34. if ($result = $mysqli->query("SELECT DATABASE()")) {
  35. $row = $result->fetch_row();
  36. printf("Default database is %s.n", $row[0]);
  37. $result->close();
  38. }
  39. /*selecciona campos de la tabla*/
  40. $sql = "SELECT date, threads, operator_msgs, user_msgs, missed_threads, avg_waiting_time, invitations_sent, invitations_accepted, invitations_rejected, invitations_ignored FROM cgchat";
  41. $result = $conn->query($sql);
  42.  
  43. if ($result->num_rows > 0) {
  44. // output data of each row
  45. while($row = $result->fetch_assoc()) {
  46. echo "date: " . $row["date"]. " threads: " . $row["threads"]. "Operator messages: " . $row["operator_msgs"]. " User messages: " . $row["user_msgs"]. "Missedthreads " . $row["missed_threads"]. "Average waiting time " . $row["avg_waiting_time"]. "Sentinvitations: " . $row["invitations_sent"]. " Acceptedinvitations: " . $row["invitations_accepted"]. "Rejectedinvitations: " . $row["invitations_rejected"]. " Ignoredinvitations: " . $row["invitations_ignored"]. "<br>";
  47. }
  48. } else {
  49. echo "0 results";
  50. }
  51.  
  52. $mysqli->close();
  53. ?>
  54.  
  55. <!DOCTYPE html>
  56. <html>
  57. <head>
  58.  
  59.  
  60. <FORM action="conex.php" method="post">
  61. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  62. <meta name="viewport" content="width=device-width,initial-scale=1">
  63. <title>DataTables example - Multiple tables</title>
  64. <link rel="shortcut icon" type="image/png" href="/media/images/favicon.png">
  65. <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.datatables.net/rss.xml">
  66. <link rel="stylesheet" type="text/css" href="/media/css/site-examples.css?_=6e5593ad4c5375eef5d919cfc10a0a54">
  67. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
  68. <style type="text/css" class="init">
  69.  
  70. div.dataTables_wrapper {
  71. margin-bottom: 3em;
  72. }
  73.  
  74. </style>
  75. <script type="text/javascript" src="/media/js/site.js?_=88b8e26b7e3dd4eee69f199f9880a0e0">
  76. </script>
  77. <script type="text/javascript" src="/media/js/dynamic.php?comments-page=examples%2Fbasic_init%2Fmultiple_tables.html" async>
  78. </script>
  79. <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.12.4.js">
  80. </script>
  81. <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js">
  82. </script>
  83. <script type="text/javascript" language="javascript" src="../resources/demo.js">
  84. </script>
  85. <script type="text/javascript" class="init">
  86.  
  87. $(document).ready(function() {
  88. $('table.display').DataTable();
  89. } );
  90.  
  91. </script>
  92. </head>
  93.  
  94. <body class="wide comments example">
  95.  
  96. <a name="top" id="top"></a>
  97. <div class="form-header">
  98. <div class="form-header-inwards"></div>
  99. </div>
  100.  
  101.  
  102. <table id="" class="display" cellspacing="0" width="100%">
  103. <thead>
  104. <tr>
  105. <th>Date</th>
  106. <th>Threads</th>
  107. <th>Operator messages</th>
  108. <th>User messages</th>
  109. <th>Missedthreads</th>
  110. <th>Average waiting time</th>
  111. <th>Sentinvitations</th>
  112. <th>Acceptedinvitations</th>
  113. <th>Rejectedinvitations</th>
  114. <th>Ignoredinvitations</th>
  115. </tr>
  116. </thead>
  117. <tfoot>
  118. <tr>
  119. <th>Total</th>
  120. <th></th>
  121. <th></th>
  122. <th></th>
  123. <th></th>
  124. <th></th>
  125. <th></th>
  126. <th></th>
  127. <th></th>
  128. <th></th>
  129. </tr>
  130. </tfoot>
  131. <tbody>
  132. <tr>
  133. <td></td>
  134. <td></td>
  135. <td></td>
  136. <td></td>
  137. <td></td>
  138. <td></td>
  139. <td></td>
  140. <td></td>
  141. <td></td>
  142. <td></td>
  143. </tr>
  144. <tr>
  145. <td></td>
  146. <td></td>
  147. <td></td>
  148. <td></td>
  149. <td></td>
  150. <td></td>
  151. <td></td>
  152. <td></td>
  153. <td></td>
  154. <td></td>
  155. </tr>
  156. <tr>
  157. <td></td>
  158. <td></td>
  159. <td></td>
  160. <td></td>
  161. <td></td>
  162. <td></td>
  163. <td></td>
  164. <td></td>
  165. <td></td>
  166. <td></td>
  167. </tr>
  168. <tr>
Add Comment
Please, Sign In to add comment