So i am trying to write code to do the following very basic thing:
*Take a number from the html input-form
*Take a counter, going from 0 to the input-number in a loop
*get the number as a list-item in the php-output, except if it is divisible by 3 or 5, which get ping and pong respectively as an output-value.
At the moment, this sadly does not work and all i get displayed is the tite & an error-message. Any and all help is very much appreciated!
Here the code from the html input-page:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<title>PHP Ping Pong Purified Perfection!</title>
</head>
<body>
<div class="container">
<h1>Geimme a number between 0 and 100 or you get a paddlin´!</h1>
<form action="phpPingPong.php" method="post">
<div class="form-group">
<label for="inputNumber">The Number:</label>
<input id="inputNumber" name="inputNumber" class="form-control" type="number">
</div>
<button type="submit" class="btn">Gimme the darn result already!</button>
</form>
</div>
</body>
</html>
Here´s the code from the php-page:
<?php
$inputNumber = $_GET["inputNumber"];
$counter = 0;
$outputMessage = "";
function colorFate($inputNumber, $outputMessage)
{
if ($inputNumber < 100){
for ( $counter == 1; $counter <= $inputNumber; $counter ++) {
if ($counter % 5 === 0 && $counter % 3 === 0){
$outputMessage = "Ping-Pong";
}
else if ($counter % 3 === 0){
$outputMessage = "Ping";
}
else if ($counter % 5 === 0){
$outputMessage = "Pong";
}
else if ($counter % 5 != 0){
$outputMessage = $counter;
}
$outputMessage = "<li>"+ $outputMessage +"</li>";
"#outputList".append ($outputMessage) ;
}
}
else{
alert("Please follow the guidelines on what to enter!");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title> PHPingPong </title>
</head>
<body>
<h1>Read and Weep!</h1>
<ul id="outputList">
</ul>
</body>
</html>
Thanks again!