[help] php

Status
Not open for further replies.

Jo$h

Posting Freak
Jul 7, 2010
1,030
79
Alright, So I am working with My First PHP Script, located below.
I've Posted it to a website,
And it works fine, but I recieve an error stating that I am Dividing by zero, and I want to remove that. If I could get help that would be great.
PHP:
<HTML>
<HEAD>
<TITLE> Assignment Worth Calculator</title>
</head>
<body><font face="Arial"><center>
<form action="index.php" method ="post">
Total Questions: <input type="text" name="TotalQs" value="25"><br>
Correct Questions: <input type="text" name="CorrectQs" value="25"><br>
<input type="submit" value="Calculate Me">
</form>
<?php
if($_POST["TotalQs"] == "0") {
echo "Assignments Generally Do Not have 0 Questions";
}

if($_POST["CorrectQs"] == "0") {
echo "You Should Already know your grade";
}

$initialProblem=$_POST["CorrectQs"]/$_POST["TotalQs"];

$step2=$initialProblem*100;

echo "Your Grade is: ";
echo "$step2";
echo "%";


?>
<br>
Created by Josh Johnston
</center>
</font>
</body>
</html>
Thanks, Jo$h
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
PHP:
<HTML>
<HEAD>
<TITLE>*Assignment*Worth*Calculator</title>
</head>
<body>
<?php
if(!isset($_POST['submit']))
{
?>
<font*face="Arial"><center>
<form*action="index.php"*method*="post">
Total*Questions:*<input*type="text"*name="TotalQs"*value="25"><br>
Correct*Questions:*<input*type="text"*name="CorrectQs"*value="25"><br>
<input*type="submit"*name='submit' value="Calculate*Me">
</form>
<?php
}else{
if($_POST["TotalQs"]*==*0)*{
echo*"Assignments*Generally*Do*Not*have*0*Questions";
}

if($_POST["CorrectQs"]*==*0)*{
echo*"You*Should*Already*know*your*grade";
}

$initialProblem=$_POST["CorrectQs"]/$_POST["TotalQs"];

$step2=$initialProblem*100;

echo*"Your*Grade*is:*";
echo*"$step2";
echo*"%";
}

?>
<br>
Created*by*Josh*Johnston
</center>
</font>
</body>
</html>
try that.
 

Benden

maging ang maganda mamatay
Jun 4, 2010
2,280
1,480
1297565742538153693583.png

that is what it goes too
 
Status
Not open for further replies.

Users who are viewing this thread

Top