peachsnapple Posted July 20, 2009 Share Posted July 20, 2009 I am having trouble displaying the item listed in my drop box. It is not showing up anything. The list is blank. I don't know what the problem is. May someone please help me solve this headache. thanks <?php // manage colors // pull associated color/products and display them // give ability to delete associations and add // Remove association if(isset($_POST['submit']) && isset($_POST['attid'])){ $q = 'DELETE FROM color_list_attribute WHERE attributeid='.$_POST['attid']; $r = mysql_query($q); if($r !== false) echo '<h2>Color Product Association removed.</h2><br><br><br>'; } // Add new color if(isset($_POST['submit']) && isset($_POST['color'])){ $r =mysql_query('INSERT INTO color_list VALUES ("","'.$_POST['color'].'")'); if($r !== false) echo '<h2>New Color Added</h2><br><br><br>'; } // Make association if(isset($_POST['submit']) && isset($_POST['colorid'])){ $r= mysql_query('INSERT INTO color_list_attribute VALUES ("",'.$_POST['colorid'].','.$_POST['productid'].')'); if($r !== false) echo '<h2>Color Product Association Complete.</h2><br><br><br>'; } // Display add new color echo '<h2>Add new color</h2>'; ?> <form action="?content=colors" method="post"> <b>Color Name</b><input type="text" name="color" value=""><input type="submit" name="submit" value="Add Color"> </form> <?php // Display add color asccoiation ****This is the Select query to call to the database*** $q = 'SELECT description,prodid FROM products'; $r = mysql_query($q); $prod_options = ''; while($row = mysql_fetch_array($r)) $prod_options .= '<option value="'.$row['prodid'].'">'.$row['description'].'</option>'; $q = 'SELECT item_color,colorid FROM color_list'; $r = mysql_query($q); $color_options = ''; while($row = mysql_fetch_array($r)) $color_options .= '<option value="'.$row['colorid'].'">'.$row['item_color'].'</option>'; ?> <br> <h2>Color Product Associate</h2> *******This is the code for the drop down box to list the items, this is where I hae the problem of it not displaying**** <form action="?content=colors" method="post"><b>Product</b> <select name="prodid"><?=$prod_options;?></select> <br> <b>Color </b><select name="colorid"><?=$color_options;?></select> <br><input type="submit" name="submit" value="Associate"> </form> Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 20, 2009 Share Posted July 20, 2009 1. You don't have any error handling on your queries. Have you verified that they are not failing and are returning results. For a quick and dirty verification and an "or die(mysql_error())" to your query calls like so: $r = mysql_query($q) or die(mysql_error()); 2. You are using PHP short tags to "write" your options to the page. These are discouraged. You should use full PHP tags: <select name="prodid"><?php echo $prod_options; ?></select> Also, did you even check the generated html code to see what was created? 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.