I need help in adding table row with the text entry when I click submit button. No database involved

I know it involves a loop but I don’t know which one to use and I don’t have the idea on how to initiate it. I’m on my 2nd week of learning php as my 1st coding language. I hope you can help. Thank you!

<table border="1">
<?php
if(isset($_POST['submit'])){
	$name = $_POST['name'];


	echo "<tr><td>" . $name . "</tr></td>";emphasized text
}




?>
</table>





<form action=""	method="post">
	<input type="text" name="name">
	<input type="submit" name="submit">
</form>

Where did you get this assignment? The issue is, PHP is stateless and will not retain the old lists without sending that data in with the data you want added. You can circumvent that by making the server stateful, meaning that it holds on to the data that you want kept, by using cookies or sessions. The way this would typically be done is, you are either inserting into a database and then pulling all of the data out to display; or the more likely, you use an AJAX call.

So, this is really a JavaScript question rather than a PHP one.

Sponsor our Newsletter | Privacy Policy | Terms of Service