Şimdi Ara

Php Mysql kullanarak her kullanıcıya özgü grafik üretmek

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir - 2 Masaüstü
5 sn
2
Cevap
0
Favori
1.785
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Merhabalar,

    Elimde şu yapıda bir mysql tablosu bulunuyor



    INSERT INTO `veriler` (`tcno`, `deger1`, `deger2`) VALUES
    ('123456789', 75, 82),
    ('234567891', 65, 85),
    ('345678912', 42, 40),
    ('456789123', 10, 35),
    ('567891234', 70, 90),
    ('678912345', 60, 80),
    ('789123456', 55, 80),
    ('891234567', 65, 95),
    ('912345678', 55, 99);




    Php kullanarak mysql'den datayı şu kodla çekiyorum

     
    <?php
    // Connect to MySQL
    $link = mysqli_connect( 'localhost', 'root', '' );
    if ( !$link ) {
    die( 'Could not connect: ' . mysqli_error() );
    }

    // Select the data base
    $db = mysqli_select_db($link, 'veriler');
    if ( !$db ) {
    die ( 'Error selecting database \'veriler\' : ' . mysqli_error() );
    }

    // Fetch the data
    $query = "
    SELECT *
    FROM my_chart_data
    ORDER BY category ASC";
    $result = mysqli_query($link, $query);

    // All good?
    if ( !$result ) {
    // Nope
    $message = 'Invalid query: ' . mysqli_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die( $message );
    }

    // Print out rows
    $prefix = '';
    echo "[\n";
    while ( $row = mysqli_fetch_assoc( $result ) ) {
    echo $prefix . " {\n";
    echo ' "tcno": "' . $row['tcno'] . '",' . "\n";
    echo ' "deger1": ' . $row['deger1'] . ',' . "\n";
    echo ' "deger2": ' . $row['deger2'] . '' . "\n";
    echo " }";
    $prefix = ",\n";
    }
    echo "\n]";

    // Close the connection
    //mysql_close($link);
    ?>








    bir index.html dosyası ile de bu php dosyasının ürettiği datayı grafiğe dönüştürebiliyorum





     
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>amCharts tutorial: Loading external data</title>
    </head>
    <body>

    <!-- prerequisites -->
    <link rel="stylesheet" href="http://www.amcharts.com/lib/style.css" type="text/css">
    <script src="http://www.amcharts.com/lib/3/amcharts.js" type="text/javascript"></script>
    <script src="http://www.amcharts.com/lib/3/serial.js" type="text/javascript"></script>

    <!-- cutom functions -->
    <script>
    AmCharts.loadJSON = function(url) {
    // create the request
    if (window.XMLHttpRequest) {
    // IE7+, Firefox, Chrome, Opera, Safari
    var request = new XMLHttpRequest();
    } else {
    // code for IE6, IE5
    var request = new ActiveXObject('Microsoft.XMLHTTP');
    }

    // load it
    // the last "false" parameter ensures that our code will wait before the
    // data is loaded
    request.open('GET', url, false);
    request.send();

    // parse adn return the output
    return eval(request.responseText);
    };
    </script>

    <!-- chart container -->
    <div id="chartdiv" style="width: 600px; height: 300px;"></div>

    <!-- the chart code -->
    <script>
    var chart;

    // create chart
    AmCharts.ready(function() {

    // load the data
    var chartData = AmCharts.loadJSON('data.php');

    // SERIAL CHART
    chart = new AmCharts.AmSerialChart();
    chart.pathToImages = "http://www.amcharts.com/lib/images/";
    chart.dataProvider = chartData;
    chart.categoryField = "category";
    chart.dataDateFormat = "YYYY-MM-DD";

    // GRAPHS

    var graph1 = new AmCharts.AmGraph();
    graph1.valueField = "value1";
    graph1.bullet = "round";
    graph1.bulletBorderColor = "#FFFFFF";
    graph1.bulletBorderThickness = 2;
    graph1.lineThickness = 2;
    graph1.lineAlpha = 0.5;
    chart.addGraph(graph1);

    //var graph2 = new AmCharts.AmGraph();
    //graph2.valueField = "value2";
    //graph2.bullet = "round";
    //graph2.bulletBorderColor = "#FFFFFF";
    //graph2.bulletBorderThickness = 2;
    //graph2.lineThickness = 2;
    //graph2.lineAlpha = 0.5;
    //chart.addGraph(graph2);

    // CATEGORY AXIS
    chart.categoryAxis.parseDates = true;

    // WRITE
    chart.write("chartdiv");
    });

    </script>

    </body>
    </html>




    Sorum şu:

    Ben her tc no için ayrı bir grafik üretmek istiyorum. index.html sayfamda tcno girilen bir kutucuk bulunsun tcnosunu giren kişi sadece kendisi için üretilen grafiği görsün. Maalesef şu anda elimde var olan codlar herkese aynı grafiği gösteriyor. kodun neresinde düzenleme yapmam gerekir.

    Yardımınız için şimdiden teşekkürler.







  • $query = "
    SELECT *
    FROM my_chart_data
    ORDER BY category ASC"

    bu kısmı

    $query = "
    SELECT *
    FROM my_chart_data
    where tckimlikno = "$tckimlik"

    gibi bir şey olmalıydı. Where ile tckimlik numarasına göre çağırırsın o grafik yapacağın tabloları. (doğruluğunu kontrol ettiğini ve benzersiz olduğunu varsayıyorum değilse kullanıcının id sine görede verileri çekebilirsin)
  • Yapay Zeka’dan İlgili Konular
    Daha Fazla Göster
    
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.