Jump to content

help with arrays


gum1982

Recommended Posts

 

Hi im new to php so sorry about my code i know its wrong that's why i need some help im making a survey form that needs to analysis the percentage from a set off questions hear is my code it works fine but as i add more questions it justs get bigger and bigger. this is just snippet of one group and their is about 20.

 

Im trying to get my head around arrays at the moment would this be the right way?

 

<?php

if (is_array($_POST) && count($_POST) > 1) {

$exercise_value = $_POST['q1'];

$exercise_value1 = $_POST['q2'];

$exercise_value2 = $_POST['q3'];

$exercise_value3 = $_POST['q4'];

}

?>

<FORM METHOD="post" ACTION="">

<table width="805" height="789">

<tr><h2>Marketing</h2></tr>

<!----- SECTION ----->

  <tr>

  <td width="688">I know where I want .....</td>

  <td width="96">

  <input type="radio" name="q1" value="1">

  <input type="radio" name="q1" value="2">

  <input type="radio" name="q1" value="3">

  <input type="radio" name="q1" value="4">

  </td>

  </tr>

 

    <tr>

  <td width="688">I have a written marketing....</td>

  <td width="96">

  <input type="radio" name="q2" value="1">

  <input type="radio" name="q2" value="2">

  <input type="radio" name="q2" value="3">

  <input type="radio" name="q2" value="4">

  </td>

  </tr>

 

      <tr>

  <td width="688">I understand the .....</td>

  <td width="96">

  <input type="radio" name="q3" value="1">

  <input type="radio" name="q3" value="2">

  <input type="radio" name="q3" value="3">

  <input type="radio" name="q3" value="4">

  </td>

  </tr>

 

      <tr>

  <td width="688" height="22">Our current prices</td>

  <td width="96">

  <input type="radio" name="q4" value="1">

  <input type="radio" name="q4" value="2">

  <input type="radio" name="q4" value="3">

  <input type="radio" name="q4" value="4">

  </td>

  </tr>

    <tr>

  <td width="688" height="20">Percentage for this section.</td>

  <td width="96"><?php echo $exercise_value*100/16+$exercise_value1*100/16+$exercise_value2*100/16+$exercise_value3*100/16 . "%";

  ?></td>

  </tr>

 

<!----- SECTION END ----->

Link to comment
https://forums.phpfreaks.com/topic/180265-help-with-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.