I am building a simple PHP checklist application which takes sentences as input which are stored in MYSQL database then the list is echoed out with remove buttons in front of each list item such as:
- 1) Do breakfast [remove button]
- 2) Go to College [remove button]
- 3) Eat Lunch [remove button]
- 4) Get back Home [remove button]
Now what would be function that will be executed to remove the current list item being removed.
Here is how I am retrieving the list from database and their corresponding remove buttons:
$sql2 = "SELECT * FROM `info` LIMIT 0, 30 ";
$arr = mysql_query($sql2);
while($data = mysql_fetch_array($arr)){
echo '<strong>'.$data['id'].')</strong>'.' '.$data['text'].'<form action="list.php" method="POST">
<input type="submit" value="Remove" />
</form>'.'<br />';
Please help me how can we approach to a situation like this.
P.S The database has two columns only “ID” and the “List item”
You can use
< input type='hidden' name='data' value="<?php echo $data[text]; ?>" >in the formFinally, you can put this block to remove.