4
I’m starting to work with PHP, MYSQL now and I’ve come up with a question.
I am developing a classified site, the same will have categories of vehicles, real estate, electronics, etc...
My question is as follows, the guy selects car for example, car has numerous features, as well as a mobile phone, an apartment, etc.. how can I record these features in BD?
Create a table for each type? (car, truck, apartment, cell phone...) not right?
Someone can give me a direction?
Remembering that all features are selected in a checkbox according to availability and advertising type.
Follow div with checkbox
<label class="col-sm-2 control-label">Características</label>
<div class="col-sm-9">
<div class="row">
<div class="col-sm-3"><input type="checkbox"> Air-Bar </div>
<div class="col-sm-3"><input type="checkbox"> Ar-Condicionado </div>
<div class="col-sm-3"><input type="checkbox"> Vidros Elétricos </div>
</div>
<div class="row">
<div class="col-sm-3"><input type="checkbox"> Flash </div>
<div class="col-sm-3"><input type="checkbox"> Câmera Frontal </div>
<div class="col-sm-3"><input type="checkbox"> GPS </div>
</div>
<div class="row">
<div class="col-sm-3"><input type="checkbox"> Tecnologia NFC </div>
<div class="col-sm-3"><input type="checkbox"> Detecção Facial </div>
<div class="col-sm-3"><input type="checkbox"> Dual Chip </div>
</div>
<div class="row">
<div class="col-sm-3"><input type="checkbox"> Biometria </div>
<div class="col-sm-3"><input type="checkbox"> HDR </div>
<div class="col-sm-3"><input type="checkbox"> Extensão para Cartão de Memória </div>
</div>
</div>
Thank you all.
The characteristics are via input or it chooses according to availability and advertising type?
– Papa Charlie
Choose via checkbox according to availability and ad type
– Eduardo Paludo
If you have a list of defined features and the user chooses the options, you just need to save the ID’s. This would not solve your case?
– Papa Charlie
But the checkbox is manually placed in the code
– Eduardo Paludo
Look there could be several ways to do what you want in my opinion. Save a single string separated by commas of the characteristics, an intermediate table ex: caracteristicas_anuncio (id_anuncio, id_caracteristica, or id_anuncio, feature_name) <- in case of saving a Tring you can make a composite key for the two fields so it does not repeat.. in order.... And one more thing, can a classifieds contain more than one category? If yes... the logic would change a little too.
– Rafael Withoeft