繁体   English   中英

如何从PHP获取变量到数组?

[英]How to get variable from php to array?

 <?php include 'config.php'; $id_tes = $_GET['id_tes']; $i = mysqli_query($db, "SELECT count(id_tes) FROM report WHERE jawaban='I' and id_tes='$id_tes' GROUP BY id_tes"); $e = mysqli_query($db, "SELECT count(id_tes) FROM report WHERE jawaban='E' and id_tes='$id_tes' GROUP BY id_tes"); $n = mysqli_query($db, "SELECT count(id_tes) FROM report WHERE jawaban='N' and id_tes='$id_tes' GROUP BY id_tes"); $s = mysqli_query($db, "SELECT count(id_tes) FROM report WHERE jawaban='S' and id_tes='$id_tes' GROUP BY id_tes"); $t = mysqli_query($db, "SELECT count(id_tes) FROM report WHERE jawaban='T' and id_tes='$id_tes' GROUP BY id_tes"); $f = mysqli_query($db, "SELECT count(id_tes) FROM report WHERE jawaban='F' and id_tes='$id_tes' GROUP BY id_tes"); $j = mysqli_query($db, "SELECT count(id_tes) FROM report WHERE jawaban='J' and id_tes='$id_tes' GROUP BY id_tes"); $p = mysqli_query($db, "SELECT count(id_tes) FROM report WHERE jawaban='P' and id_tes='$id_tes' GROUP BY id_tes"); $dataPoints1 = array( array("label"=> "Intorvert dan Extrovert", "y"=> 56), array("label"=> "Sensing dan Intuition", "y"=> 76), array("label"=> "Thinking & Feeling", "y"=> 89), array("label"=> "Judging & Perceiving", "y"=> 35) ); $dataPoints2 = array( array("label"=> "Intorvert dan Extrovert", "y"=> 75), array("label"=> "Sensing dan Intuition", "y"=> 43), array("label"=> "Thinking & Feeling", "y"=> 54), array("label"=> "Judging & Perceiving", "y"=> 34) ); ?> 

如何获取php中变量的值以显示在数组中以替换数字值(56、76、89、35、75、43、54、34)作为变量计数($ i的结果) ,$ e,$ n等)。

谢谢。

foreach( $dataPoints1 as $key=>$item ) {
    echo $item['y'];
    echo $item['label']
    //replace
    $dataPoints1[$key]['y'] = $replace_value;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM