0
<?php

// url nya: abcd.com/jumlahklik.php?idads=[idadsnya]

$con = mysql_connect("localhost","root","");

mysql_select_db("freescript", $con);

// kalo ada yg click  tambahkan jumlah klik 

$count = 0;
if ($_GET['idads']==1)
{
$count++;

$waktu = date('Y-m-d H:i:s');
$idads = 1;
$date = date('Y-m-d');
$time = date('H:i:s');

mysql_query("insert into adsmgt (idads,waktu,date,time) values ('$idads', '$waktu', '$date', '$time')");

}

//di jumlahklik.php tinggal bikin script buat save ke database

//dibawahnya tinggal kasih header("location:alamat url aslinya");exit();


// print jumlah klik dalam graphic


$result = mysql_query("SELECT COUNT(idads) AS countidads FROM adsmgt") or die(mysql_error()); 

$resultday = mysql_query("SELECT COUNT(idads) AS countidadsday FROM adsmgt GROUP BY date") or die(mysql_error());

while($row = mysql_fetch_assoc($result))
{
echo "Number of ad clicks: ".$row['countidadsday'];

}

$result2 = mysql_query("SELECT waktu, date, time FROM adsmgt") or die(mysql_error());

echo "<br>";
echo "<br>"."Tanggal"."&nbsp&nbsp&nbsp"."&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspWaktu"."&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspJumlah clicks per hari";

while($row2 = mysql_fetch_array($result2))
{
echo "<br>".$row2['date']."&nbsp&nbsp&nbsp".$row2['time']."&nbsp&nbsp&nbsp".$row['countidadsday'];
}

while($rowday= mysql_fetch_array($resultday))
{
echo $rowday['countidadsday'];
}

//php_info();

// Graph - http://www.ebrueggeman.com/phpgraphlib/examples

?>

    <html>
    <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart);
    function drawChart() {
    var data = google.visualization.arrayToDataTable([
    ['date', 'Number of clicks per hari'],
    <?php
    $data = array(
    '1'=>array('date'=>'2013-01-16','numclicks'=>'6'),
    '2'=>array('date'=>'2013-01-17','numclicks'=>'9'),
    '3'=>array('date'=>'2013-01-18','numclicks'=>'5'),
    '4'=>array('date'=>'2013-01-19','numclicks'=>'12'),
    '5'=>array('date'=>'2013-01-20','numclicks'=>'10'),
    );
    //$resultday = mysql_query("SELECT `date`,COUNT(idads) AS `numclicks` FROM adsmgt GROUP BY date") or die(mysql_error());
    $i = 0;
    //while($row = mysql_fetch_assoc($resultday)){
    foreach($data as $row){
    if($i == 0){
    echo "['{$row['date']}', {$row['numclicks']}]";
    }else{
    echo ",['{$row['date']}', {$row['numclicks']}]";
    }
    $i++;
    }
    ?>
    ]);
    var options = {
    title: 'Company Performance',
    hAxis: {title: 'Date', titleTextStyle: {color: 'red'}}
    };
    var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
    chart.draw(data, options);
    }
    </script>
    </head>
    <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
    </body>
    </html>

Notice: Undefined index: countidadsday in C:\xampp\htdocs\Innovation\script_shop\adsmgt.php on line 40

line 40: echo "Number of ad clicks: ".$row['countidadsday'];

Tanggal(date) waktu (time) Jumlah clicks per hari(number of clicks each day)

2013-01-23 03:25:03
2013-01-23 03:29:28
2013-01-23 03:40:12
2013-01-23 03:40:45
2013-01-23 03:41:25 4012114112352611255

I wonder where: 4012114112352611255 comes from?

3
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by davy_yg
0

appologize. I thought I would give more space for commenting since my previous post already have around 20 replies.

0

@davy_yg
Please keep to a single thread. You may alienate contributors who may take it that you're dissatisfied with their input thus far.

0

ok. I'll close this thread. Still please help me with the previous thread. Thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.