nvd80
08-14-2005, 01:07 PM
when i choose few items from the list in the main page, it will open a new page which will display the no of item choosed and the particular colors. the problem is, when i hit the select button, it prompt "you had choose 0 color.." then there is error at my foreach function..
1st file selectcolour.php
<html>
<head>
<title>Task 4</title>
</head>
<body>
<table width="42%" border="1" align="center">
<form name="page1" action="displaycolour.php">
<tr>
<td><div align="center"><strong>Please Select Your Favourite Colour:</strong></div></td>
</tr>
<tr>
<td height="89">
<div align="center">
<select name="selcolour[]" multiple="multiple" size="4">
<option>yellow</option>
<option>blue</option>
<option>green</option>
<option>orange</option>
<option>red</option>
<option>purple</option>
</select>
</div></td>
</tr>
<tr>
<td><p align="center"><input type="submit" name="submit" value="Select"></p></td>
</tr>
</form>
</table>
</body>
</html>
2nd file: displaycolour.php
<html>
<head>
<title>Display Colour</title>
</head>
<body>
<?php
echo "You had selected ".count($selcolour)." colours. They are :<br/>";
foreach ($selcolour as $c=>$col)
{
echo $col;
}
?>
</body>
</html>
1st file selectcolour.php
<html>
<head>
<title>Task 4</title>
</head>
<body>
<table width="42%" border="1" align="center">
<form name="page1" action="displaycolour.php">
<tr>
<td><div align="center"><strong>Please Select Your Favourite Colour:</strong></div></td>
</tr>
<tr>
<td height="89">
<div align="center">
<select name="selcolour[]" multiple="multiple" size="4">
<option>yellow</option>
<option>blue</option>
<option>green</option>
<option>orange</option>
<option>red</option>
<option>purple</option>
</select>
</div></td>
</tr>
<tr>
<td><p align="center"><input type="submit" name="submit" value="Select"></p></td>
</tr>
</form>
</table>
</body>
</html>
2nd file: displaycolour.php
<html>
<head>
<title>Display Colour</title>
</head>
<body>
<?php
echo "You had selected ".count($selcolour)." colours. They are :<br/>";
foreach ($selcolour as $c=>$col)
{
echo $col;
}
?>
</body>
</html>