Jump to content

Can you do this? Convert list items into entries in database and more...


lfernando

Recommended Posts

I coded the following but some parts are not working (the "curveball" mentioned at the end).

How would YOU do this? :shrug:

 

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
Share on other sites

"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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.