I'm working on simple app that add array items on button click and display the values on click.
My problem is after adding the items to array I cant display the values.
Hope you help me.
HTML
<form action="" method="POST">
<button name="save">save</button>
<button name="display">display</button>
</form>
PHP
$arr = array();
if (isset($_POST['save'])) {
$items = array('Mark', '12', 'Japan');
array_push($arr, $items);
}
if (isset($_POST['display'])) {
print_r($arr);
}
print_r($arr)?$arrvariable with the items and never saved them, but than when you clicked on the display button it recreated the$arrarray as an empty list. To do this, on the save button you need to store that data somewhere like a database or a file, and than on the display button retrieve that data first and than display it.