Guest User

Untitled

a guest
Apr 12th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.50 KB | None | 0 0
  1. <?php
  2.    
  3.     $servername = "localhost";
  4.     $username = "root";
  5.     $password = "root123";
  6.     $dbname = "test";
  7.    
  8.     $AdName=[];
  9.     $TotalView=[];
  10.     $TotalMaleView=[];
  11.     $TotalFemaleView=[];
  12.     $rowcount=0;
  13.    
  14.     // Create connection
  15.     $con = mysqli_connect($servername, $username, $password, $dbname);
  16.     // Check connection
  17.     if ($con->connect_error)
  18.     {
  19.         die("Connection failed: " . $con->connect_error);
  20.     }
  21.  
  22.     $result=mysqli_query($con,"SELECT `Ad Name`,`Total View Count`, `Total Female Viewers`, `Total Male Viewers` FROM `addata` WHERE `Disp Id`=1");
  23.  
  24.     $rowcount=mysqli_num_rows($result);
  25.    
  26.     if(!$result)
  27.     {
  28.         die('Could not get data: ' . mysql_error());
  29.     }
  30.     // output data of each row
  31.     for($x = 0; $x < $rowcount; $x++)
  32.    {
  33.         $row = $result->fetch_assoc();
  34.         $TotalView[$x]=$row["Total View Count"];
  35.         $TotalFemaleView[$x]=$row["Total Female Viewers"];
  36.         $TotalMaleView[$x]=$row["Total Male Viewers"];
  37.         $AdName[$x]=$row["Ad Name"];
  38.     }
  39.  
  40.     $con->close();
  41. ?>
  42. <html>
  43.     <body>
  44.         <script src="https://www.gstatic.com/charts/loader.js"></script>
  45.         <ul id="stats"></ul>
  46.         <script type="text/javascript">
  47.            
  48.             var array1 = <?php echo json_encode($TotalView);?>;
  49.             var array2 = <?php echo json_encode($TotalFemaleView);?>;
  50.             var array3 = <?php echo json_encode($TotalMaleView);?>;
  51.             var array4 = <?php echo json_encode($AdName);?>;
  52.                            
  53.             google.charts.load('current',
  54.             { callback: function ()
  55.                 {  
  56.                     for (var y = 0; y < array1.length; y++)
  57.                     {
  58.                         array1[y]=eval(array1[y])
  59.                         array2[y]=eval(array2[y])
  60.                         array3[y]=eval(array3[y])
  61.                        
  62.                         var data = new google.visualization.DataTable();
  63.                         data.addColumn('string', 'list');
  64.                         data.addColumn('number', 'Viewers');
  65.                         data.addRows([
  66.                                         ['TotalViewers',array1[y]],
  67.                                         ['Female Viewers', array2[y]],
  68.                                         ['Male Viewers', array3[y]]
  69.                                     ]);
  70.                         var options = {title:array4[y],width:400,height:300};
  71.  
  72.                         var container = document.getElementById('stats').appendChild(document.createElement('div'));
  73.                         var chart = new google.visualization.ColumnChart(container);
  74.                         chart.draw(data, options);
  75.                     }
  76.                 },
  77.                 packages: ['corechart']
  78.             });
  79.         </script>
  80.     </body>
  81. </html>
  82.  
  83.  
  84. <!--
  85. <?php
  86.     echo "Downloading File...";
  87.     file_put_contents("C:\Users\Admin\Videos\PHPDownloadTest.mp4", file_get_contents("http://localhost/xibo/Library/39.mp4"));
  88. ?>
  89. -->
Add Comment
Please, Sign In to add comment