munky334 Posted October 19, 2008 Share Posted October 19, 2008 Hi there The following script wont run , I get the error below. Any advice? Warning - Invalid argument supplied for foreach() - Line 36 Thanking you in advance <?php /* File: shop_page_index.inc * Desc: Displays the categories for the catalog. */ ?> <html> <head><title>The Furniture Shop</title> <style type='text/css'> <!-- ul li { list-style: none; font-weight: bold; padding-top: .5em; font-size: 1.2em; } ul li.level2 { margin-left: -1em; font-weight: normal; font-size: .9em; } --> </style> </head> <body style="margin: .2in"> <?php /* Display text before form */ echo "<form action='Shop_cart.php' method='POST'>\n <p style='text-align: right'>\n <input type='submit' value='View Shopping Cart'>\n </form>\n"; echo "<h1 style='text-align: center'>The Furniture Shop</h1> <hr>"; /* Create form containing selection list */ echo "<form action='$_SERVER[php_SELF]' method='POST'>\n"; echo "<ul>\n"; foreach($furn_categories as $key => $subarray) { echo "<li>$key</li>\n"; echo "<ul>\n"; foreach($subarray as $type) { echo "<li class='level2'> <input type='radio' name='interest' id='$type' value='$type'> <label for='$type'>$type</label></li>\n"; } // end foreach type echo "</ul>\n"; } //end foreach category echo "</ul>"; echo "<input type='submit' name='Products' value='Select Category' style='margin-left: .5in’>\n"; echo "</form>\n"; ?> <hr> </body></html> EDIT: code tags code tags code tags Link to comment https://forums.phpfreaks.com/topic/129062-invalid-argument-supplied-for-foreach/ Share on other sites More sharing options...
ratcateme Posted October 19, 2008 Share Posted October 19, 2008 where does $furn_categories come from it is nothing so it can't be an array so you can't run a foreach on it Scott. Link to comment https://forums.phpfreaks.com/topic/129062-invalid-argument-supplied-for-foreach/#findComment-669099 Share on other sites More sharing options...
munky334 Posted October 19, 2008 Author Share Posted October 19, 2008 thanx scott Link to comment https://forums.phpfreaks.com/topic/129062-invalid-argument-supplied-for-foreach/#findComment-669254 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.