Here is my code:
for($i = 0; $i < $printcoll->getlineCount(); $i++){
$li = $printcoll->getLineItem($i);
$item = $li->getItem();
if($item instanceof Product){
print "Bike ID - ";
}
print $item->getId();
if($item instanceof Product){
print "  Price £";
}
print $item->getPrice();
if($item instanceof Product){
print "  Quantity - ";
}
print $li->getQuantity();
print "<a href='myOO.php?delete=" . $i . "'>Delete</a>";
echo "</br>";
}
if(isset($_GET['delete'])){
$id = $_GET['delete'];
$li = $printcoll->getLineItem($id);
$printcoll->delLineItem($li);
}
This code deletes the object the user specifies (by clicking the a href). However, after clicking delete, the page does not go back to "myOO.php". It stays as "myOO.php?delete=".$i." and so i have to manually delete the "?delete=".$i." bit out of the address bar for the update to appear on the page. Any ideas?
One solution is putting ob_start(); at the start of the page, and then putting header('location:myOO.php') in the if statement. However im not sure this is the correct way of doing this. Any ideas? Thanks
Ask kennypu already pointed out, PHP code is executed on the webserver.
This means that everytime you change the document on the server, the page must be reloaded on the client manually or automatically ( e.g. by using AJAX ) in order to re-execute the PHP code on the server.