how do I translate the category names into integer to be stored in the book table?
I have a database with three tables; books, categories and authors.
instead of storing author and category names inside the book table I simply reference them using author_id and category_id respectively.
Books will be added via a form, and one of the form input is category. Now it's unintuitive to use category_id because users don't know what each category_id will stand for so I simply displayed the available category within a selection tag so they can choose one of the available categories.
Here's the problem, the category_id in the book table expects an integer, how do I translate the category names into integer to be stored in the book table?
instead of storing author and category names inside the book table I simply reference them using author_id and category_id respectively.
Books will be added via a form, and one of the form input is category. Now it's unintuitive to use category_id because users don't know what each category_id will stand for so I simply displayed the available category within a selection tag so they can choose one of the available categories.
Here's the problem, the category_id in the book table expects an integer, how do I translate the category names into integer to be stored in the book table?
No any search results
You already invited:
1 Answers
Dmitry
Upvotes from: