jenneke Posted May 8, 2007 Share Posted May 8, 2007 hello all, this is my first entry in the forum. i am making an cms to add and modify entries into a database. everything is going well except the modify page. the page gets the id of the entry, the text area but when it tries to collect the list/menu, it displays them as one long line, not as a drop down menu. does anyone know what could be the problem? code below with problem area in red: <h3>Links</h3> <form name="form1" method="post" action="links_update.php?id='.$id.'> <p> <br> <select name="area" size="1"> <option selected>' . $row["area"] . '</option> <option>Footprint calculators</option> <option>Water saving</option> <option>Energy saving</option> <option>Home</option> <option>Garden</option> <option>Directory services</option> <option>At work</option> <option>Environmental labelling</option> <option>Recycling</option> <option>Investment</option> <option>Food</option> <option>Shopping</option> <option>Travel</option> <option>For the Kids</option> <option selected>Green groups</option> <option selected>Miscellaneous</option> </select> <br> <input name="website" type="text" size="53" value="'.htmlentities($row['website']).'"> : Website <br> </p> <p> <textarea name="details" cols="40" rows="5">' . $row["details"] . '</textarea> : Details<br> Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/ Share on other sites More sharing options...
marcus Posted May 8, 2007 Share Posted May 8, 2007 Instead of ' . $row["field"] . ' Do either: ".$row['field']." OR $row[field] Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247736 Share on other sites More sharing options...
jenneke Posted May 8, 2007 Author Share Posted May 8, 2007 Thanks for the quick response. It still doesn't work. The selected value does appear at the start of the row, so that doesn't seem to be the problem. It looks like it is having trouble recognising the drop down menu as a drop down menu. Any other suggestions? Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247742 Share on other sites More sharing options...
john010117 Posted May 8, 2007 Share Posted May 8, 2007 I'm not sure, but maybe it's because of the size attribute. Try removing the size altogether. Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247745 Share on other sites More sharing options...
jenneke Posted May 8, 2007 Author Share Posted May 8, 2007 still no improvement. Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247759 Share on other sites More sharing options...
john010117 Posted May 8, 2007 Share Posted May 8, 2007 Maybe it's because you have two options selected at the same time. <option selected>' . $row["area"] . '</option> and <option selected>Miscellaneous</option> Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247764 Share on other sites More sharing options...
mmarif4u Posted May 8, 2007 Share Posted May 8, 2007 Can u show the complete code with mysql query. Also select one value from one dropdown menu, u r selecting multiple items.remove that, select only one. It depends on ur mysql query if u r geting the rows from db. Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247774 Share on other sites More sharing options...
jenneke Posted May 8, 2007 Author Share Posted May 8, 2007 Here is the code with only one field selected. Thank you for your time, Jenneke $result=mysql_query("SELECT * FROM links WHERE id='$id'"); if ($row=mysql_fetch_array($result)) { echo ' <br><br><br> <h3>Links</h3> <form name="form1" method="post" action="links_update.php?id='.$id.'> <p> <br> <select name="area"> <option selected>' . $row["area"] . '</option> <option>Footprint calculators</option> <option>Water saving</option> <option>Energy saving</option> <option>Home</option> <option>Garden</option> <option>Directory services</option> <option>At work</option> <option>Environmental labelling</option> <option>Recycling</option> <option>Investment</option> <option>Food</option> <option>Shopping</option> <option>Travel</option> <option>For the Kids</option> <option>Green groups</option> <option>Miscellaneous</option> </select> <br><br> <input name="website" type="text" size="53" value="'.htmlentities($row['website']).'"> : Website <br> </p> <p> <textarea name="details" cols="40" rows="5">' . $row["details"] . '</textarea> : Details<br> <br> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> '; } else { echo '<br><br>sorry, this entry does not exist<br><br>'; } mysql_close(); include('footer.html'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247804 Share on other sites More sharing options...
mmarif4u Posted May 8, 2007 Share Posted May 8, 2007 $sql="select * from links where id='$id'"; $result = mysql_query($sql) or die(mysql_error()); while($row= mysql_fetch_object($result)){ echo "<option value='{$row->area}' selected='selected'>{$row->area}</option>";} Modify ur code to this way. Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247822 Share on other sites More sharing options...
jenneke Posted May 8, 2007 Author Share Posted May 8, 2007 The change in code you suggested does call up the correct value from the database but when i view the form, the other options still appear in one long line instead of as a drop down menu. Example: Miscellaneous Footprint calculators Water saving Energy saving Home Garden Directory services At work Environmental labelling Recycling Investment Food Shopping Travel For the Kids Green groups Miscellaneous Note that the selected value 'miscellaneous' has appeared at the start indicating that the code you (mmarif4u) suggested worked. But how can I make it appear as a drop down menu instead of this long line of text? Quote Link to comment https://forums.phpfreaks.com/topic/50431-php-form-modify-page/#findComment-247844 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.