如何在网页上显示实时图表

I've been working on this for some days now but I can't seem to find the answer. I have a webpage which displays a question and answers to choose from and when you click submit it goes to the next question. The problem is trying to display the results after each question as a bar chart on a webpage. I'm trying to make the server push one question first and when an answer is picked, the chart is updated in realtime. I've gone through so many socket with php tutorials but I'm still finding it hard. I'm using Composer to work with client and server. I tried and tested out sending messages from the server to a client webpage which worked but that didn't really help as I'm trying to update with client input.

The testing code below counts and displays the number of votes after a question. The data doesn't enter the database at the moment as I've been trying to do that and it's not entering.

    <?php 
if(isset($_GET['question'])){
$connection = mysqli_connect('localhost', 'root', '', 'quiz');
$question = preg_replace('/[^0-9]/', "", $_GET['question']);
$sql2 = mysqli_query($connection,"SELECT * FROM answers WHERE question_id='$question' ORDER BY rand()");
            while($row2 = mysqli_fetch_array($sql2)){
                $answer = $row2['answer'];
                $correct = $row2['correct'];
                $answers .= '<label style="cursor:pointer;"><input type="radio" name="rads" value="'.$correct.'" onclick="getVote(this.value)" >'.$answer.'</label>                 
                ';

                        }   
            }
$vote = isset($_GET['rads']);
                //get content of textfile
$filename = "poll_result.txt";
$content = file($filename);

//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];

if ($vote == 0) {
  $yes = $yes + 1;
}
if ($vote == 1) {
  $no = $no + 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>

<h2>Result:</h2>
<table>
<tr>
<td>Yes:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($yes/($no+$yes),2)); ?>'
height='20'>
<?php echo(100*round($yes/($no+$yes),2)); ?>%
</td>
</tr>
<tr>
<td>No:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($no/($no+$yes),2)); ?>'
height='20'>
<?php echo(100*round($no/($no+$yes),2)); ?>%
</td>
</tr>
</table> 
<?php if(isset($_GET['question'])){?>
<span id="btnSpan"><button onclick="post_answer()">Submit</button></span><?php }?>
<?php

If the chart is displayed from the database, it's not updating realtime. I want the chart updated after user input. Any ideas will be very helpful.