hello.
i have a function which i need a little help with, please.
the idea is that on each page i have any number of placeholders and inside each placeholder there can be any number of elements.
so for example:
page ID 1 has 3 placeholders.
place holder 1 has 1 elements
place holder 2 has 5 elements
place holder 3 has 7 elements
or what ever....
when a page loads it tells my code the pageID which then gets from the db the placeholder numbers and the elements for each placeholder.
it all seems to work if i only put 1 element in to each placeholder but if i try to put more than 1 element i dont get anything back.
this is how my tables are set out:
in the elements db i have just the id and name:
ID NAME
1 E1
2 E2
3 E3
4 E4
5 E5
etc....
in the placeholder db i have :
id pages_id contElements_id phNumber
1 1 1 1
2 1 5 2
3 1 7 3
etc....
MY FIRST QUESTION IS:
they will pick the elements using tick boxes so how would they be added in the contElements_id ??
should i use varchar, enum or set
and should they be input like this:
id pages_id contElements_id phNumber
1 1 1 1
2 1 4, 5, 6 2
3 1 9, 10, 11 3
etc....
or this
id pages_id contElements_id phNumber
1 1 '1' 1
2 1 '4', '5', '6' 2
3 1 '9', '10', '11' 3
etc....
or some other way?
MY SECOND QUESTION IS:
once i have all the elements in the database how do i pull them out so they list on the page ?
this is the function im using to get the correct elements for each placeholder:
if i only have 1 element in the contElements_id it works but if i add more it breaks.
function include_admin_contElements($phNo, $pageID){
$pha = Placeholders::find_by_pageID($pageID);
foreach ($pha as $phas){
$PHceA = $phas->contElements_id;
$PHnA = $phas->phNumber;
$CEa = Contelements::find_all();
foreach ($CEa as $CEas){
$CEidA = $CEas->id;
$CEnameA = $CEas->name;
if($PHceA == $CEidA && $PHnA == $phNo){
echo $CEnameA."<br/>";
}
}
}
}
this is the code on the page
$pageID = "1";
$phNo = "1";
echo include_admin_contElements($phNo, $pageID);
$phNo = "2";
echo include_admin_contElements($phNo, $pageID);
$phNo = "3";
echo include_admin_contElements($phNo, $pageID);
this part of the code echos out the element for the placeholder
if($PHceA == $CEidA && $PHnA == $phNo){
echo $CEnameA."<br/>";
}
basically its saying if placeholder contElements_id is the same as contElements id
and phNumber is the same as the pageID then echo the element name.
i have tried an explode but that did not seem to work.
HOPE THAT ALL MAKES SENCE
ANY IDEAS / THOUGHTS ???
thanks
ricky