HI can someone tell me where I'm going wrong with this code. For some reason the variable $BlogType;
isn't going through the Switch statement. This variable is set using a HTML drop-down and I have tested that its value changes accordingly with the user choice using the echo statement at the beginning of the code.
But It doesn't seem to be going past the first 'break;' in the statement, as the echo statement in the Switch code below isn't printed:
echo "<br /> value in case " . $BlogType;
echo "<br /> Blog " . $BlogType; // OK, value changes with dropdown choice
function getParameter($param, $defaultValue) {
if (array_key_exists($param, $_GET)) {
$value=$_GET[$param];
return isSet($value)?$value:$defaultValue;
}
return $defaultValue;
}
$BlogType = getParameter("blog_type", "defaultValue");
$byDate = getParameter("by_date", "defaultValue");
$loopArr = array();
switch ($BlogType) {
case 0:
$loopArr = $all_posts;
break;
case 1:
$loopArr = $music_matters->posts;
echo "<br /> value in case " . $BlogType;
break;
case 2:
$loopArr = $staff_student_news->posts;
break;
case 3:
$loopArr = $kbs_news_events->posts;
break;
default:
$loopArr = array();
}
?>
<?php foreach ($loopArr as $post): {
{ // code here
value in case " . $BlogType; } break;` – Evan Carslake Apr 19 '17 at 14:52