<?php
require_once("../../../wp-load.php");
global $wpdb; 
$PGPath=plugins_url()."/clickbar_gold/";

$ID=$_POST['I'];

$re=" SELECT * FROM ".$wpdb->prefix . "clickbar WHERE C_ID='$ID' ";
$row = $wpdb -> get_results($re);
foreach( $row as $rows ) {
                         $ClickBarName=$rows->ClickBarName;
                         $CountDownDate=$rows->CountDownDate;
                         $BarText=$rows->BarText;
                         $ButtonText=$rows->ButtonText;
                         $BarColor=$rows->BarColor;
                         $BarTexture=$rows->BarTexture;
                         $RedirectURL=$rows->RedirectURL;
                         $Position=$rows->Position;
                         $EndText=$rows->EndText;
                         $CountDownTime=$rows->CountDownTime;
                         $BarTextColor=$rows->BarTextColor;
                         }
                         
$Hits=0;
$re=" SELECT * FROM ".$wpdb->prefix . "clickbar_hits WHERE ForBar='$ID' ";
$row = $wpdb -> get_results($re);
foreach( $row as $rows ) {
                          $Hits=$Hits+1;                        
                         }   

$Clicks=0;
$re=" SELECT * FROM ".$wpdb->prefix . "clickbar_clicks WHERE ForBar='$ID' ";
$row = $wpdb -> get_results($re);
foreach( $row as $rows ) {
                          $Clicks=$Clicks+1;                        
                         } 

if ($Hits>0){
            $Conversion=round(($Clicks/$Hits)*100,'2');                                                 
            }else{
                  $Conversion=0;
                 }

?>                                 

<div style="width:600px; margin-left:auto; margin-right:auto;">                    
<h3> Bar Stats: <?php echo $ClickBarName; ?></h3>

<b>Total hits: </b><?php echo $Hits; ?><br>
<b>Total clicks: </b><?php echo $Clicks; ?><br>
<b>Conversion rate: </b><?php echo $Conversion; ?>%<br>
</div>