AJAX Poll: The PHP File

Which language do you like the most?

C/C++      Java      Lisp      Perl      PHP      Prolog      Python
The page on the server called by the JavaScript is a PHP file called PollVote.php as below. The value is sent from the JavaScript, and the following happens:
  1. Get the content of the PollResult.txt file where we store the data from the poll. It is stored like this:
    4||3||11||17||7||1||1
    The first number represents the C/C++ votes, the second number represents the Java votes, etc.

  2. Put the content of the file in variables and add one to the selected variable.

  3. Write the result to the PollResult.txt file.

  4. Output a graphical representation of the poll result.
<?php
  $vote = $_REQUEST['vote'];
  // Get content of textfile.
  $filename = "PollResult.txt";
  $content = file( $filename );

  // Put content in array.
  $array  = explode( "||", $content[0] );
  $C      = $array[0];
  $Java   = $array[1];
  $Lisp   = $array[2];
  $Perl   = $array[3];
  $PHP    = $array[4];
  $Prolog = $array[5];
  $Python = $array[6];

  switch ( $vote ) {
    case 0:  $C      += 1;  break;
    case 1:  $Java   += 1;  break;
    case 2:  $Lisp   += 1;  break;
    case 3:  $Perl   += 1;  break;
    case 4:  $PHP    += 1;  break;
    case 5:  $Prolog += 1;  break;
    case 6:  $Python += 1;  break;
  }

  // Insert votes to txt file.
  $insertVote  = $C   . "||" . $Java   . "||" . $Lisp . "||" . $Perl . "||";
  $insertVote .= $PHP . "||" . $Prolog . "||" . $Python;
  $fp = fopen( $filename, "w" );
  fputs ( $fp, $insertVote );
  fclose( $fp );
?>

<?php $total = $C + $Java + $Lisp + $Perl + $PHP + $Prolog + $Python; ?>
<table>
  <tr>
    <td rowspan="7">
      Results: (Total votes = <?php echo( $total ); ?>)
    </td>
    <td>C/C++:</td>
    <td>
      <img src='poll.gif' height='20'
        width = '<?php echo( 100*round($C/$total, 2) ); ?>' />
      <?php echo( 100*round($C/$total, 2) ); ?>%
    </td>
  </tr>
  <tr>
    <td>Java:</td>
    <td>
      <img src='poll.gif' height='20'
        width = '<?php echo( 100*round($Java/$total, 2) ); ?>' />
      <?php echo( 100*round($Java/$total, 2) ); ?>%
    </td>
  </tr>
  <tr>
    <td>Lisp:</td>
    <td>
      <img src='poll.gif' height='20'
        width = '<?php echo( 100*round($Lisp/$total, 2) ); ?>' />
      <?php echo( 100*round($Lisp/$total, 2) ); ?>%
    </td>
  </tr>
  <tr>
    <td>Perl:</td>
    <td>
      <img src='poll.gif' height='20'
        width = '<?php echo( 100*round($Perl/$total, 2) ); ?>' />
      <?php echo( 100*round($Perl/$total, 2) ); ?>%
    </td>
  </tr>
  <tr>
    <td>PHP:</td>
    <td>
      <img src='poll.gif' height='20'
        width = '<?php echo( 100*round($PHP/$total, 2) ); ?>' />
      <?php echo( 100*round($PHP/$total, 2) ); ?>%
    </td>
  </tr>
  <tr>
    <td>Prolog:</td>
    <td>
      <img src='poll.gif' height='20'
        width = '<?php echo( 100*round($Prolog/$total, 2) ); ?>' />
      <?php echo( 100*round($Prolog/$total, 2) ); ?>%
    </td>
  </tr>
  <tr>
    <td>Python:</td>
    <td>
      <img src='poll.gif' height='20'
        width = '<?php echo( 100*round($Python/$total, 2) ); ?>' />
      <?php echo( 100*round($Python/$total, 2) ); ?>%
    </td>
  </tr>
</table>