Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. <html lang="en">
  2. <head>
  3.  
  4.  
  5. </head>
  6. <script src="js1/jquery.js" type="text/javascript"></script>
  7.  
  8.  
  9. <script type="application/javascript" src="js1/awesomechart.js"> </script>
  10.  
  11. <br>
  12. <table width="610" border="0"><tr><td>
  13.  
  14. <div class="container">
  15.  
  16. <div class="row-fluid">
  17.  
  18. <div class="span12">
  19.  
  20. <div class="hero-unit-table">
  21.  
  22.  
  23. <div class="charts_container">
  24. <div class="chart_container">
  25. <div class="alert alert-info" style='color: rgba(0, 0, 0, 1);
  26. text-shadow: 0 1px 0 brown;
  27. font-size: 20px;
  28. font-family:"trebuchet ms", arial, "liberation sans"'>&nbsp;&nbsp;&nbsp;&nbsp;Product Statistic</div>
  29. <canvas id="chartCanvas1" width="1100" height="400">
  30. Your web-browser does not support the HTML 5 canvas element.
  31. </canvas>
  32.  
  33. </div>
  34. </div>
  35.  
  36.  
  37. <div class="container">
  38.  
  39. <div class="row-fluid">
  40.  
  41. <div class="span12">
  42.  
  43. <div class="hero-unit-table">
  44.  
  45.  
  46. <div class="charts_container">
  47. <div class="chart_container">
  48. <div class="alert alert-info" style='color: rgba(0, 0, 0, 1);
  49. text-shadow: 0 1px 0 brown;
  50. font-size: 20px;
  51. font-family:"trebuchet ms", arial, "liberation sans"'></div>
  52. <canvas id="chartCanvas1" width="1100" height="40">
  53. Your web-browser does not support the HTML 5 canvas element.
  54. </canvas>
  55.  
  56. </div>
  57. </div>
  58.  
  59.  
  60.  
  61.  
  62.  
  63. </div>
  64.  
  65.  
  66.  
  67.  
  68. <script type="application/javascript">
  69.  
  70. var chart1 = new AwesomeChart('chartCanvas1');
  71.  
  72.  
  73. chart1.data = [
  74. <?php
  75. $query = mysql_query("select * from transactions") or die(mysql_error());
  76. while ($row = mysql_fetch_array($query)) {
  77. $product_array = $row["product_id_array"];
  78. $product_id_string = rtrim($product_array, ",");
  79. $id_str_array = explode(",", $product_id_string);
  80. foreach ($id_str_array as $key => $value) {
  81. $id_quantity_pair = explode("-", $value); // Uses Hyphen(-) as delimiter to separate product ID from its quantity
  82. $product_id = $id_quantity_pair[0]; // Get the product ID
  83. $product_quantity = $id_quantity_pair[1]; // Get the quantity
  84. }?>
  85. <?php echo $product_quantity . ','; ?>
  86. <?php }; ?>
  87. ];
  88.  
  89. chart1.labels = [
  90. <?php
  91. $query = mysql_query("select * from transactions") or die(mysql_error());
  92. while ($row = mysql_fetch_array($query)) {
  93. $date = $row['payment_date'];
  94. $product_array = $row["product_id_array"];
  95. $product_id_string = rtrim($product_array, ",");
  96. $id_str_array = explode(",", $product_id_string);
  97. foreach ($id_str_array as $key => $value) {
  98. $id_quantity_pair = explode("-", $value); // Uses Hyphen(-) as delimiter to separate product ID from its quantity
  99. $product_id = $id_quantity_pair[0]; // Get the product ID
  100. $product_quantity = $id_quantity_pair[1]; // Get the quantity
  101. $sql = mysql_query("SELECT pname FROM products WHERE id='$product_id' ");
  102. while($row = mysql_fetch_array($sql)){
  103. $product_name = $row["pname"];
  104. }
  105. } ?>
  106. <?php echo "'" . $product_name . ' ' . $date . "'" . ','; ?>
  107. <?php }; ?>
  108. ];
  109. chart1.colors = ['red', 'blue', 'green', 'yellow', 'violet', 'brown'];
  110. chart1.randomColors = true;
  111. chart1.animate = true;
  112. chart1.animationFrames = 30;
  113. chart1.draw();
  114.  
  115.  
  116.  
  117. </script>
  118.  
  119.  
  120. </div>
  121.  
  122. </div>
  123. </div>
  124. </td>
  125. </tr>
  126. </table>
  127. </body>
  128. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement