What I am trying to do is, I need to generate a from which will ask for all the attributes of given products. I am having 4 different type of product. One of the product type is group product and when a product is group product we need to navigate through all the sub products of the group product, and ask for the attribute of all sub products. I don't want to have duplication of code based on product type so try to use PHP Eval() function to start and close a loop when ever it is required. But some how it is not working, can some one please hepl me?
Here is my code,
//To Get Product Information we will call getProductInfo function
$arrProdInfo = getProductInfo($prodId);
$pName = $arrProdInfo['name'];
$pCode = $arrProdInfo['code'];
$pType = $arrProdInfo['producttype'];
//Define two Empty variable in which we will store the string to evaluate through PHP Eval() function
$topStr1 = "";
$botStr1 = "";
//If the product type is G(Group Product) then we need to loop through all the products within this group
if ($pType == "G") {
//To fetch all the products within a group product we will call getGroupProd function
$rsltGroupProd = getGroupProd($prodId);
//Set the first string to star the loop
$topStr1 = "while($rowGroupProd = $rsltGroupProd->fetchAssoc()){
$prodId = $rowGroupProd['relproductid'];
if(!is_numeric($prodId)) $prodId = 0;
$pName = $rowGroupProd['name'];
$pCode = $rowGroupProd['code'];
$pType = $rowGroupProd['producttype'];
";
//Set second string to close the loop
$botStr1 = "}";
}
//Eval() should start the loop if it's a Group Product else will not do noting
eval($topStr1);
//A big form to fetch all the attributes of product will be generated here
//Eval() should end the loop if it's a Group Product else will not do noting
eval($botStr1);