Editing the number of foreign key records in another table depending on the value of a text box RRS feed

  • Question

  • User972233924 posted

    I have 2 tables, Clubs and pitches. For the CRUD functionality of the Club details, I have it so that the pitches details are edited when the edit club button is pressed and the user can't alter these at all since they're repeditive.  One of the fields for editing the club is a textbox called <g class="gr_ gr_1812 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="1812" data-gr-id="1812">NoOfPitches</g> for the admin to change up or down the count that the club has. 

    What would be the best way to check this number and either add or delete extra records in the pitches table. Each record in the pitches has a unique PitchID for each pitch, a foreign key linking it to the ClubID associated, other details in the Pitch table are ClubName, NoOfPitches, PitchName (Pitch 1, Pitch 2 etc). 

    I was thinking of a way which involved seeing what numbers in the <g class="gr_ gr_2138 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="2138" data-gr-id="2138">NoOfPitches</g> field and comparing with whats there already by taking or adding onto the last record, another way was just to delete all associated pitches before adding the new number of pitches in but I'm not sure if this would work with the foreign keys. 

    If anyone could help me on this I'd really appreciate it.



    Sunday, February 18, 2018 2:08 PM

All replies