0

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;
				}
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by rajabhaskar525
0

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.

0

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];
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.