Do I need to create columns in phpmyadmin for each checkbox I've created?

-1

I'm creating a hotel site for a school project, and I wonder if for every checkbox I created in the code, do I have to create a column in the phpmyadmin database? And how do I store that choice of checkbox there in the database?

Note: I'm using xampp

<div id="quartos">
       <div id="junior"> <input type="checkbox" name="quarto[]" value="op1"/> Suíte Júnior<br /></div>
       <div id="duplo"> <input type="checkbox" name="quarto[]" value="op2"/> Quarto Solteiro Duplo<br /></div>
       <div id="casal1"> <input type="checkbox" name="quarto[]" value="op3"/> Quarto Casal<br /></div>
       <div id="vista"> <input type="checkbox" name="quarto[]" value="op4"/> Apartamento Luxo vista para a cidade <br /></div>
       <div id="luxo1"> <input type="checkbox" name="quarto[]" value="op5"/> Apartamento Luxo <br /></div>
       <div id="master1"> <input type="checkbox" name="quarto[]" value="op6"/> Suíte Master <br /></div>
</div>
    
asked by anonymous 10.07.2017 / 18:57

1 answer

1

What will decide how the data will be saved in the database will be the Entity and Relationship Model ( MER ) elaborated. As mentioned in the question, you have created a website geared towards the hospitality industry. And according to the following example, we can observe a MER of the hotel industry.

Please note that the host has a relationship with the booking, which in turn with the room and the room with the room type.

Intheimagebelow,whodrewtheMERindicatedthatthewaytosavetheroomtypewillbethroughtherelation,where:1roomhas0or1room_type.Andtheroom_typecancontain1orn(more)rooms.

Yourquestionis,howshouldIsavethetypeofroomchosenbythehost?A:FollowingtherationalelogicofthisMER,thequartotablewillhaveaforeignkeyofthetipo_quartotable.Thatis,youcanfollowthisconceptandcreateatipo_quartotable,andeverytimethehostbookaroom,youwillhavetosavetheidorcodigo,accordingtoMER,ofthetipo_quartotableinthequartotable.%.

Itwouldbemoreinterestingtouseaselectcontainingtheroomtypeoptionsandforeach<option>passtheid.Butifyouwanttocontinuewithdiv's,foreachvalue="" of <input/> it must contain an id.

Then following the logic presented. You do not need to create a column in the database for every tipo_quarto . If you have any further questions just comment.

    
10.07.2017 / 21:23