Hello,
I have a problem displaying the results of a form.
Right now when I complete and send the form to DB I get results ok, but I want to know when someone is checking a value from the first question what checked in other questions dependig on the fist question .
The first question I want to be about domain of activity so I want to know and to display the result dependig on the fist question, so I want to know what are the answers to other questions depending of the answer of the first question !
So basically to have results displayed differt depending on the first question answers !
This is a part of my html form :
Question1?
<br>Productie<input type="radio" name="domeniu_activitate" VALUE="0" CHECKED />
<br>Materiale<input type="radio" name="domeniu_activitate" VALUE="1" />
<br>Administratie<input type="radio" name="domeniu_activitate" VALUE="2" />
<br>Management<input type="radio" name="domeniu_activitate" VALUE="3" />
<br>Rework<input type="radio" name="domeniu_activitate" VALUE="4" />
<br>Engineering<input type="radio" name="domeniu_activitate" VALUE="5" />
<br><br>
Question2?
<br>mai putin de 6 luni <input type="radio" name="de_cat_timp_lucrati" VALUE="0" CHECKED />
<br>intre 6 luni si 1 an<input type="radio" name="de_cat_timp_lucrati" VALUE="1" />
<br>intre 1 - 2 ani<input type="radio" name="de_cat_timp_lucrati" VALUE="2" />
<br>intre 2 - 3 ani <input type="radio" name="de_cat_timp_lucrati" VALUE="3" />
<br>mai mult de 3 ani<input type="radio" name="de_cat_timp_lucrati" VALUE="4" />
This is my connection for sending results to DB :
<?php
$con = mysql_connect("127.0.0.1","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Baza de date", $con);
$sql="INSERT INTO Tabel_bzd (domeniu_activitate,de_cat_timp_lucrati)
VALUES
('$_POST[domeniu_activitate]','$_POST[de_cat_timp_lucrati]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
This is my query for displaying results :
<?php
$con = mysql_connect("127.0.0.1","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Baza de date", $con);
//$result = mysql_query("SELECT * FROM Tabel_bzd");
echo "<b><p class='one'>Question1? </p></b><br>";
$i=0;
while($i<6)
{
$result = mysql_query("SELECT COUNT(*) as suma FROM Tabel_bzd WHERE domeniu_activitate = ". $i ." ");
while($row = mysql_fetch_array($result))
{
switch ($i)
{
case 0:
echo "Productie: ";
echo $row['suma'];
break;
case 1:
echo "<br>Materiale: ";
echo $row['suma'];
break;
case 2:
echo "<br>Administratie: ";
echo $row['suma'];
break;
case 3:
echo "<br>Management: ";
echo $row['suma'];
break;
case 4:
echo "<br>Rework: ";
echo $row['suma'];
break;
default:
echo "<br>Engineering: ";
echo $row['suma'];
}
}
$i++;
}
echo "<br><br><b><p class='one'> Question2?</p></b>";
$i=0;
while($i<5)
{
$result = mysql_query("SELECT COUNT(*) as suma FROM Tabel_bzd WHERE de_cat_timp_lucrati = ". $i ." ");
while($row = mysql_fetch_array($result))
{
switch ($i)
{
case 0:
echo "<br>mai putin de 6 luni: ";
echo $row['suma'];
break;
case 1:
echo "<br>intre 6 luni si 1 an: ";
echo $row['suma'];
break;
case 2:
echo "<br>intre 1 2 ani: ";
echo $row['suma'];
break;
case 3:
echo "<br>intre 2 3 ani: ";
echo $row['suma'];
break;
default:
echo "<br>mai mult de 3 ani: ";
echo $row['suma'];
}
}
$i++;
}
mysql_close($con);
?>