i've just noticed a type in mine - of course it's not meant to be a ":" at the end of the last elseif, it's supposed to be a ")".
And i'm sorry to say that mine is not the same as yours - it's different in exatly the way it should be: yours checks the action variable and then echoes one of three things as a result. But it will always echo the lage chunk of HTML out at the end, since there's no code to tell it not to.
Mine, on the other hand, checks to see if $action matches one of the three values listed. Only if it doesnt match any of them does it echo out the large portion of html - you'll see that the closing bracket you mention is actually matching an opening bracket that contains the else clause - in this case all the HTML.
You could achieve the same effect with yours by including a
default:
to the end of your cases, but still inside the switch:
<?php
if(isset($_GET['action']))
$action = $_GET['action'];
else
$action = '0';
switch ($action) {
case 'add':
echo "Add.";
break;
case 'edit':
echo "Edit.";
break;
case 'delete':
echo "Delete.";
break;
default:
?>
<html>
<title></title>
<body>
<a href="/checkbook/index.php?action=add">Add</a><br>
<a href="/checkbook/index.php?action=edit">Edit</a><br>
<a href="/checkbook/index.php?action=delete">Delete</a><br>
</body>
</html>
<?php
break;
}
note i've also included the isset() function, because if you've got your global variables turned off then you have to tell it to take the variable from the URL (hence the $_GET).
I'm still not too sure what that "if(empty($action)) {
$type = '';
} " is for though, so i've replaced it with an if statement that checks to see if $action has been set, and if it hasnt then it set's it to zero.