a small question
Posted: Thu Dec 24, 2009 2:10 pm
hi dears. i have a tiny question:
in index.html, i have this line:
<input name="numcourse" type="text" id="numcourse" disabled="disabled" />
in the course.php i have this:
for($i=0;$i<=$numcourse;$i++)
{
echo("course ". $i .": <input type=text name=txt".$i." /><br/>");
echo("<br/");
}
and in the result.php i write this code:
<form method="post" action="Statistics.php">
<p> <?php
//$txt0=$_POST['txt0'];
//$txt1=$_POST['txt1'];
//$txt2=$_POST['txt2'];
//$txt3=$_POST['txt3'];
//$txt4=$_POST['txt4'];
//$txt5=$_POST['txt5'];
//$txt6=$_POST['txt6'];
//$txt7=$_POST['txt7'];
//$txt8=$_POST['txt8'];
//$txt9=$_POST['txt9'];
//$txt10=$_POST['txt10'];
//$txt11=$_POST['txt11'];
//$txt12=$_POST['txt12'];
//$txt13=$_POST['txt13'];
//$txt14=$_POST['txt14'];
for($i=0; $i<=$_POST['txt'];$i++)
{
$txt[$i]+=1;
}
?>
<?php
echo "<b>";
echo "You Have Entered These Informaition: ";
echo "<br>";
echo "<br>";
echo "</b>";
echo "Student Number : ".$_SESSION['stnum'];
$stdnum=$_SESSION['stnum'];
echo "<br>";
echo "Name : ".$_SESSION['name'];
$name=$_SESSION['name'];
echo "<br>";
echo "Last Name : ".$_SESSION['lstname'];
$lstname=$_SESSION['lstname'];
echo "<br>";
echo "Major : ".$_SESSION['major'];
$major=$_SESSION['major'];
echo "<br>";
echo "Year : ".$_SESSION['year'];
$year=$_SESSION['year'];
echo "<br>";
echo "<br>";
//$average=(($txt0+$txt1+$txt2+$txt3+$txt4+$txt5+$txt6+$txt7+$txt8+$txt9+$txt10)/5);
$sex=$_SESSION['Sex'];
//$max=max($txt0,$txt1,$txt2,$txt3,$txt4,$txt5,$txt6,$txt7,$txt8,$txt9,$txt10);
echo "The Maximum Number Is : ". $max;
echo "<br>";
echo "The Average Is: ".$average;
echo "<br>";
echo "<br>";
echo "<b>";
$sql="INSERT INTO `STDB` ( `Name` , `Major` , `Year` , `Max` , `Avg` )
VALUES (
'$name', '$major', '$year', '$max', '$average'
);
";
$r=mysql_query($sql);
if($sex==1 and $average>=15)
echo 'congratulation!! You Are a Successful Man';
else
if($_SESSION['Sex']==2 and $average>17)
echo 'congratulation!! You Are a Successful Lady';
echo "<br>";
echo "<br>";
?>
but it is totally wrong.
i just wanna make text boxes as i entered in the index.html and then put then in variables, calculate their max and average and then put them all in the mysql database.
how i can do them?
please help me.
in index.html, i have this line:
<input name="numcourse" type="text" id="numcourse" disabled="disabled" />
in the course.php i have this:
for($i=0;$i<=$numcourse;$i++)
{
echo("course ". $i .": <input type=text name=txt".$i." /><br/>");
echo("<br/");
}
and in the result.php i write this code:
<form method="post" action="Statistics.php">
<p> <?php
//$txt0=$_POST['txt0'];
//$txt1=$_POST['txt1'];
//$txt2=$_POST['txt2'];
//$txt3=$_POST['txt3'];
//$txt4=$_POST['txt4'];
//$txt5=$_POST['txt5'];
//$txt6=$_POST['txt6'];
//$txt7=$_POST['txt7'];
//$txt8=$_POST['txt8'];
//$txt9=$_POST['txt9'];
//$txt10=$_POST['txt10'];
//$txt11=$_POST['txt11'];
//$txt12=$_POST['txt12'];
//$txt13=$_POST['txt13'];
//$txt14=$_POST['txt14'];
for($i=0; $i<=$_POST['txt'];$i++)
{
$txt[$i]+=1;
}
?>
<?php
echo "<b>";
echo "You Have Entered These Informaition: ";
echo "<br>";
echo "<br>";
echo "</b>";
echo "Student Number : ".$_SESSION['stnum'];
$stdnum=$_SESSION['stnum'];
echo "<br>";
echo "Name : ".$_SESSION['name'];
$name=$_SESSION['name'];
echo "<br>";
echo "Last Name : ".$_SESSION['lstname'];
$lstname=$_SESSION['lstname'];
echo "<br>";
echo "Major : ".$_SESSION['major'];
$major=$_SESSION['major'];
echo "<br>";
echo "Year : ".$_SESSION['year'];
$year=$_SESSION['year'];
echo "<br>";
echo "<br>";
//$average=(($txt0+$txt1+$txt2+$txt3+$txt4+$txt5+$txt6+$txt7+$txt8+$txt9+$txt10)/5);
$sex=$_SESSION['Sex'];
//$max=max($txt0,$txt1,$txt2,$txt3,$txt4,$txt5,$txt6,$txt7,$txt8,$txt9,$txt10);
echo "The Maximum Number Is : ". $max;
echo "<br>";
echo "The Average Is: ".$average;
echo "<br>";
echo "<br>";
echo "<b>";
$sql="INSERT INTO `STDB` ( `Name` , `Major` , `Year` , `Max` , `Avg` )
VALUES (
'$name', '$major', '$year', '$max', '$average'
);
";
$r=mysql_query($sql);
if($sex==1 and $average>=15)
echo 'congratulation!! You Are a Successful Man';
else
if($_SESSION['Sex']==2 and $average>17)
echo 'congratulation!! You Are a Successful Lady';
echo "<br>";
echo "<br>";
?>
but it is totally wrong.
i just wanna make text boxes as i entered in the index.html and then put then in variables, calculate their max and average and then put them all in the mysql database.
how i can do them?
please help me.