i have a multiple select drop down menu where i select some courses however my problem is that i was to store the selected courses in an array for further use. i have tried creating an array but is is coming up empty. Can someone help me out here
here is the code where i was to store the courses in an array

$store=array();
			@$code1= $_POST['coursecode_1'];
			if( is_array($code1))
			{
				echo "The Course(s) that you have selected are:<br> ";
					//$sum= array();
				while (list ($key, $val1) = each ($code1)) 
				{
					$store[]=$val1;
					//echo $val1;
					$c="SELECT * FROM courses WHERE course_code= '$val1'";
					$r=mysql_query($c);
					$m=mysql_fetch_assoc($r);
					extract($m);
					echo "$course_name<br>";
					echo $store;
				}

i have a multiple select drop down menu where i select some courses however my problem is that i was to store the selected courses in an array for further use. i have tried creating an array but is is coming up empty. Can someone help me out here
here is the code where i was to store the courses in an array

$store=array();
			@$code1= $_POST['coursecode_1'];
			if( is_array($code1))
			{
				echo "The Course(s) that you have selected are:<br> ";
					//$sum= array();
				while (list ($key, $val1) = each ($code1)) 
				{
					$store[]=$val1;
					//echo $val1;
					$c="SELECT * FROM courses WHERE course_code= '$val1'";
					$r=mysql_query($c);
					$m=mysql_fetch_assoc($r);
					extract($m);
					echo "$course_name<br>";
					echo $store;
				}

first thing: i really dont think $code1 is an array since it is assigned the value of $_POST. so the if statement wont be executed.

use implode to store multiple values

if($_POST['coursecode_1'])
	{
	$store=implode(",",$_POST['coursecode_1']);
	}

use explode to split the string.

$s=explode(",",$store);
  for($=0;$i<count($s);$i++)
{
echo $s[$i];
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.