Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
128
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $conn = new mysqli('localhost', '**', '', 'test');
  3. if ($conn->connect_error) {
  4. die("Connection failed: " . $conn->connect_error);
  5. }
  6.  
  7. $query = "select * from table01 ";
  8. $result = $conn->query($query);
  9. while($row2 = mysqli_fetch_assoc($result))
  10. {
  11. $arr2[]=$row2;
  12. }
  13.  
  14. $row=count($arr2);
  15. for($i = 0; $i < $row; $i++) {
  16.  
  17. $dat[$arr2[$i]['date1']]=1; //делаем уникальную дату(ключь не может повторятся)
  18. $name[$arr2[$i]['bluch_title']]=2;//делаем уникальное название(ключь не может повторятся)
  19. }
  20.  
  21. echo '<table border="1">';
  22.  
  23. echo '<tr>';
  24. echo '<td>Name';
  25. foreach ($dat as $key => $value) {
  26. echo'<td>'.$key;
  27. }
  28. echo '</td>';
  29. echo '</tr>';
  30. $set=count($dat);
  31.  
  32. foreach ($name as $key1 => $value1) {
  33.  
  34.  
  35. foreach ($dat as $key => $value) {
  36. $query0 = "select * from table01 where date1='".$key."' and bluch_title='".$key1."'";
  37. $result2 = $conn->query($query0);
  38. while($row21 = mysqli_fetch_assoc($result2))
  39. {
  40. $arr21[]=$row21['bluch_views'];
  41. }
  42. }}
  43. $res=array_chunk($arr21, $set, TRUE); //разбиваем массив
  44. foreach ($res as $key6 => $value6) {
  45. # code...
  46. $fud[]=array_values($value6); //пересоздаём ключи во вложенном массиве
  47. }
  48.  
  49. $k='-1';
  50.  
  51. foreach ($name as $key1 => $value1) {
  52. $k++;
  53. echo'<tr><td>'.$key1;
  54. for($ii = 0; $ii < $set; $ii++) {
  55. echo '<td>'.$fud[$k][$ii];
  56. }
  57. echo '</td>';
  58. }
  59. echo '</table>';
  60. ?>
Advertisement
RAW Paste Data Copied
Advertisement