I pretty new at PHP (also my first question here).
I have created a button, when you click on it I want the values in an array to show up on the page. (And would also like the values to show up randomly everytime you click on the button if possible.)
I do not want to use any JavaScript, only PHP, HTML and CSS. Any help highly appreciated!
JavaScript
x
$months= array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December" );
foreach ($months as $month) {
echo $month . "<br>";
}
<input type="submit" name="submit" value="Submit">
Advertisement
Answer
You can put a if()
condition to check the name posted and if yes it echoes the array
You can try the following
JavaScript
if($_POST['submit'] === 'Submit'){
foreach ($months as $month) {
echo $month . "<br>";
}
}
<input type="submit" name="submit" value="Submit">
Note : Assign the second Submit
with capital S after the operator.