How can I say in/with the follow (see below) function that you can make max 3 items? And if you will make more than three items the function will stop and you get a warning?
function addSection() {
global $compid;
$sectionOb = new Item();
$sectionOb->i_id_pk = $sectionOb->newId();
$sectionOb->i_mod_comp_id_fk = $compid;
$sectionOb->c_titel = '';
$sectionOb->c_content = '';
$sectionOb->i_sort = $sectionOb->newSort($compid);
$sectionOb->insert();
}
if($action == 'add') {
addSection();
}
<a href="<?php echo $_SERVER['REQUEST_URI'] ?>&action=add" />new section</a>
If you are not too concerned about URL spoofing, I would add a counter variable in the URL which is passed to the addSection() method like so: