redarrow Posted October 24, 2008 Share Posted October 24, 2008 advance thank you... hi there done this to show a user how to make multipule cheek box's i have added the array_count_values at the end off the last swith off com.... ur see i have printed the array condition out with print_r and it showing the correct array info.. but array count values tell me that $computer not a array... what i done wrong thank u................... <?php echo"<table align='center'><tr><td align='left'><center><a href='".$_SERVER['PHP_SELF']."?cmd=a'>Select Cat!</a> <br><br></center></tr></td></table>"; if($_GET['cmd']=="a"){ $c=array("Food","Plants","Computers"); echo"<table align='center'><tr><td align='left'><form method='POST' action='".$_SERVER['PHP_SELF']."'>"; foreach($c as $cat){ echo"<tr><td><input type='checkbox' name='cat' value='$cat'>$cat<br></td></tr>"; } echo"<tr><td><br><br><input type='submit' name='submit' value='Choose Cat'><br><br></tr></td>"; echo"</form></center></table></td></tr>"; } if(isset($_POST['submit'])){ $cat=$_POST['cat']; switch($cat){ CASE "Food": $c=array("Burger","Chips","Sasuages"); echo"<table align='center'><tr><td align='left'><form method='POST' action='".$_SERVER['PHP_SELF']."'>"; foreach($c as $food){ echo"<tr><td><input type='checkbox' name='food' value='$food'>$food<br></td></tr>"; } echo"<tr><td><br><br><input type='submit' name='foods' value='Choose food'><br><br></td></tr>"; echo"</form><center></table></td></tr>"; BREAK; case "Plants": $c=array("Trulips","Rose","Sunflower"); echo"<table align='center'><tr><td align='left'><form method='POST' action='".$_SERVER['PHP_SELF']."'>"; foreach($c as $plant){ echo"<tr><td><input type='checkbox' name='plant' value='$plant'>$plant<br></center></td></tr>"; } echo"<tr><td><br><br><input type='submit' name='plants' value='Choose plants'><br><br></td></tr>"; echo"</form></center></table></tr></td>"; BREAK; case "Computers": $c=array("Apple","Pc","Atri"); echo"<table align='center'><tr><td align='left'><form method='POST' action='".$_SERVER['PHP_SELF']."'>"; foreach($c as $computers){ echo"<tr><td><input type='checkbox' name='computer[]' value='$computers'>$computers<br></td></tr>"; } echo"<tr><td><br><br><input type='submit' name='com' value='Choose computer'><br><br></td></tr>"; echo"</form></table></td></tr>"; BREAK; } } if($_POST['foods']){ $food=$_POST['food']; echo "<center><h1>$food</h1><center>"; switch($food){ CASE "Burger": echo" <center> <img src='http://tbn0.google.com/images?q=tbn:vorDPsJ-f6DBaM:http://brothersburger.com.ph/images/burger-pounder.jpg'></center>"; BREAK; CASE "Chips": echo "<center><img src='http://tbn0.google.com/images?q=tbn:FViS5OolWH005M:http://www.freefoto.com/images/9905/05/9905_05_31---Chips-with-salt-and-vinegar_web.jpg</center>"; BREAK; CASE "Sasuages": echo "<center><img src='http://tbn0.google.com/images?q=tbn:p6RaeFy06cxJpM:http://www.meandlous.com/images/Sasuage.jpg'></center>"; BREAK; } } if($_POST['plants']){ $plant=$_POST['plant']; echo "<center><h1>$plant</h1><center>"; switch($plant){ CASE "Trulips": echo" <center> <img src='http://tbn0.google.com/images?q=tbn:PUGaH5yNuRCDwM:http://artbymukkekawoman.com/gallery/gallery1-1.jpg'></center>"; BREAK; CASE "Rose": echo "<center><img src='http://tbn0.google.com/images?q=tbn:Pi3jJvWjSs5jZM:http://www.victorianrose.org/images/red_rose2.jpg'></center>"; BREAK; CASE "Sunflower": echo "<center><img src='http://tbn0.google.com/images?q=tbn:M5JqfoG53CMFdM:http://www.web-enz.co.nz/images/sunflowerAll.GIF'></center>"; BREAK; } } if($_POST['com']){ $computer=$_POST['computer']; print_R($computer); echo array_count_values($computer); //not working....... if(array_count_values($computer )< 2){ echo "<br><br><center><h1>PLEASE ONLY SELECT 1 ITEM AT A TIME!<h1></center><br><br>"; exit; }else{ $computer=implode(' ',$computer); echo "<center><h1>$computer</h1><center>"; switch($computer){ CASE "Apple": echo" <center> <img src='http://tbn0.google.com/images?q=tbn:hoAV9CG8skUBjM:http://www.katize.com/wp-content/uploads/2007/08/apple_computer_logosvg.png'></center>"; BREAK; CASE "Pc": echo "<center><img src='http://tbn0.google.com/images?q=tbn:BApwPL3NmoFSeM:http://www.cheaplaptops.org.uk/wp-content/laptopimg/2007/06/packard-bell-2391.jpg'></center>"; BREAK; CASE "Atri": echo "<center><img src='http://tbn0.google.com/images?q=tbn:tTZWky8jlKJZJM:http://www.arti.com.hk/media/logo.gif'></center>"; BREAK; } } } ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 24, 2008 Author Share Posted October 24, 2008 forget it sorry............... tired wrong code syntex......... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.