lfernando Posted December 9, 2010 Share Posted December 9, 2010 I coded the following but some parts are not working (the "curveball" mentioned at the end). How would YOU do this? I have a page (A) displaying a form with a textarea field using a WYSIWYG interface. The user will enter a list of unordered items and upon submit the string will look something like this: This is my list of food items: <ul> <li> Lettuce </li> <li> Tomatoes </li> <li> Eggs </li> <ul> Upon submit, I need to give each list item an unique id and store this id along with the text next to it in a separate table: List_item_id List_item_text List_item_state food_1 Lettuce food_2 Tomatoes food_3 Eggs The user will then land in another page with a form displaying the list. The text is now in the page itself and not in a textarea. Instead of the bullets a dropdown list appears, and the user can select "buy" or "sell" for each list item. This page (B) looks something like this: <form> This is my list of food items: <br><select name="food_1"> <option value="buy">Buy</option> <option value="sell">Sell</option> </select> Lettuce <br><select name="food_2"> <option value="buy">Buy</option> <option value="sell">Sell</option> </select> Tomatoes <br><select name="food_2"> <option value="buy">Buy</option> <option value="sell">Sell</option> </select> Eggs <input type=submit value="submit"> </form> When the user hits "submit" the table with the list items will be updated with the values selected in the dropdown list: List_item_id List_item_text List_item_state food_1 Lettuce Buy food_2 Tomatoes Buy food_3 Eggs Sell The next time the user goes to Page B the list will remember the states. Here's the curveball: At any point the user may click on "EDIT LIST" on Page B so they may add more items (at the begining, middle or end of the string). On edit mode the list items should appear as bullets again inside the WYSIWYG interface. Keep in mind that some of the text in the string may not be a list item (ie, "this is my list of food...") Link to comment https://forums.phpfreaks.com/topic/221126-can-you-do-this-convert-list-items-into-entries-in-database-and-more/ Share on other sites More sharing options...
Anti-Moronic Posted December 9, 2010 Share Posted December 9, 2010 "Upon submit, I need to give each list item an unique id" You need to set this to an auto-incremented column and assign it as the index. That will then automatically create unique id's for you. On your list output, I think it would be better to have checkboxes next to your food items instead of a dropdown for each. Would look cleaner and be more intuitive. On the 'curveball', I think you need to elaborate a little more. Do you mean it should be updated in real time? Basically, you want consistency between the data on both pages. Apart from that, are you asking for what code you would use to do this? If so, I'd advise you check out the manual and mysql tutorials. It's very simple stuff so shouldn't take you long sussing it out. Link to comment https://forums.phpfreaks.com/topic/221126-can-you-do-this-convert-list-items-into-entries-in-database-and-more/#findComment-1144957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.