I have been trying to create a simple site that uses the CRUD operators. I am having some trouble with the delete function. I have a button for each row that when clicked will delete the row. The code below shows the what I am doing for the button, I am trying to call to a function called getItems() which is i itemsDAO(), Unfortunately this is where I am having trouble. I cant seem to get this to work and to have the results from getItems() enter the $uid.
I know if I hard code in the value in the form the row will be deleted, so I have narrowed it down to the PHP code at the top. Any help will be great as I have been stuck on this for a long time now.
PHP Form Code
<?php
$this = new ItemsDAO();
$result=$itemsDAO->getItems();
foreach ($result as $row) {
$uid = $row['id'];
?>
<form action="index.php" method="post">
<fieldset>
<input id='action' type='hidden' name='action' value='deleteItem' />
<p>
<div class="form-group">
<div class="controls">
<input type="hidden" id="fID" name="uid" value="<?php echo $uid; ?>">
<input type="submit" class="btn btn-success" value="Delete">
</div>
</div>
</p>
</fieldset>
</form>
<?php } ?>
ItemsDAO->getItems()
public function getItems () {
$sqlQuery = "SELECT *";
$sqlQuery .= " FROM items";
$result = $this->getDbManager()->executeSelectQuery($sqlQuery );
return $result;
}