problem with updating data into Joined tables

Status
Niet open voor verdere reacties.

artisy2014

Nieuwe gebruiker
Lid geworden
24 dec 2014
Berichten
1
1 What I want:
• Let users create a news item using a form
• The news item must be connected to a tournament.

2 Database tables
Table Toernooien (Toernooi_id, Naam_Toernooi)
Table Nieuws (Nieuws_id, Nieuwstitel, Nieuwsbericht, Publicatiedatum, Toernooi_id)


3 My form
form_news.jpg

4 validating the form and inserting data to database
Most of this part is not a problem.
But I can't figure 1 thing out:
- How can I set the Tournament_id (Toernooi_id) for a news item?

In the form I want the user to select the Tournament by name(from table one) which works.
But then I need something to convert the selected Tournament into the related Tournament_id. and the Tournament_id that belongs to the new item has to be inserted into the News table.
 
Dit forum is volledig nederlandstalig, dus je mag je vraag ook gewoon in het nederlands stellen.

Wanneer je de dropdown aanmaakt, doe je dat waarschijnlijk met een server-side taal (PHP?). Als je daarvoor de entries uit je tabel toernooien opvraagt, zowel met id als naam; ken je ervoor zorgen dat de resulterende html iets in deze richting wordt:
HTML:
<select name="gelinktToernooi">
     <option value="">--toernooi--</option>
     <option value="1">Test</option>
     <option value="2">Halve Finale</option>
</select>
Dus je zorgt ervoor dat het Toernooi_id als value van de option komt te staan.

Wanneer je dan je formulier verzend, zal aan de serverside kant het id van het geselecteerde toernooi doorgestuurd zijn. Je kan deze value dan toevoegen aan je insert-statement.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan