I have a mysql table with questions IDs (q_ID) and answers (a_answer). I want to use this data to populate some html later in the doc. Some of the data is separated by '|' and I want to use switch to filter. I am having trouble accessing the data by key. It works within while loop, but I need it outside.
$getData="SELECT a_answer, q_ID FROM answers ";
$result = mysqli_query($connected, $getData);
while($row = mysqli_fetch_assoc($result))
{
$arAnswer = explode('|', $row['a_answer']);
//catagorize by number of values
$arrayCount = count($arAnswer);
switch ($arrayCount)
{
case 1: //short data, no separators
//make array for ID and answer
$q = $row['q_ID'];
$a = $arAnswer[0];
$x = array($q=>$a);
break;
}; //END switch
}; //END while
Later in the doc, echo does not return value/$a for $q:
echo $x[1]
Thanks,