This is fairly involved, so here it goes:
I have two tables. one named pages, the other, content. The pages table has a field named content. it's a text field with values ie; contentOne contentTwo contentThree etc.. each one has a \n after it.
I am querying for the pages like this:
$pageQuery = mysql_query("SELECT * FROM pages WHERE id = '111111' LIMIT 0, 1");
$page = mysql_fetch_assoc($pageQuery);
after that i use explode to create an array with the data from the content column:
$contentArray = explode("\n", $page['content']);
once that is done, i use foreach to loop through the array. while it's looping, i am querying the content table for the content by using the $value from the array.
foreach($contentArray as $value) {
${"{$value}Query"} = mysql_query("SELECT content FROM content WHERE contentArea = '".$value."' ORDER BY id ASC LIMIT 0, 1");
${"{$value}Result"} = mysql_fetch_assoc(${"{$value}Query"});
$$value = ${"{$value}Result"}['content'];
}
I am dynamically naming the query, query results, and resulting var so it won't be overwritten during the loop.
My end goal is to be able to call the variables later in the page outside the loop.
<div id="contentOne"><?=$contentOne;?></div>
<div id="contentTwo"><?=$contentTwo;?></div>
etc...
My issue is that, even though it's dynamically naming everything within the loop, it will still only display the last value from the loop, as if it's still overwriting what was before it.
I know this is maybe not the perfect solution, but it is pretty much a requirement for how i need this set up. anyone see anything obvious that's wrong here? It seems my logic is fairly solid, I'm just missing something.
Any help would be much appreciated.