根据多个选中的复选框创建直方图

时间:2014-03-16 16:27:25

标签: php html mysql checkbox google-visualization

我有一个复选框列表,现在我能够从多个选中的复选框中检索数据库中的数据,并将它们显示在一个表格中......下面是代码..

但我的问题是如何在 comparetable.php 中显示类似输出数据到直方图 ..我试图用谷歌图表,但它只是显示数据库中的直方图数据,而不是来自多个选中的复选框。非常感谢你的时间......

history.php

<FORM NAME ="form1" METHOD ="POST" action="comparetable.php">
<table>

         <tr>
        <th></th>
        <th>TITLE</th>
        <th>ACTION</th>
         </tr>

     <?php
        $query = "SELECT * FROM compareresult where idmember='$idmembersession'";
    $sql_query = mysql_query($query) or die('Error 3 :'.mysql_error());
    while($data = mysql_fetch_array($sql_query,MYSQL_ASSOC)){

                        $title = $data['subject'];
          ?>

        <tr>
        <td><input type="checkbox" name="selectedcheck[]" 
       value="<?php  echo $title ?>"/></td>

        <?php
        echo "<td>$title</td>"
        }
        ?>
        </tr>
 </table> 

  <INPUT TYPE = "Submit" Name = "submit1"  VALUE = "COMPARE SELECTED"></form>

comparetable.php

<body>SUSTAINABILITY OF PERCENTAGE </br></br></br>

<table border='1'>
<tr>
<th>TITLE</th>
<th>PERCENTAGE RESULT</th>
</tr>

<?php 

 if(isset ($_POST["submit1"]))
{
$checkbox = isset($_POST['selectedcheck']) ? $_POST['selectedcheck'] :  array();
foreach($checkbox as $title)
    {

    $query = "SELECT * FROM compareresult where subject='".$title."'";
    $sql_query = mysql_query($query) or die('Error 3 :'.mysql_error());
        while($data = mysql_fetch_array($sql_query))
        {

                $result = $data['result'];

                echo "<tr>";
                echo "<td>".$title."</td>";
                echo "<td>".$result."</td>";    
                echo "</tr>";   
        }
    }
}

?>
</table></body></html>

0 个答案:

没有答案