How to save radio button data in a database and extract it?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Remco

    #1

    How to save radio button data in a database and extract it?

    Hello,

    I'm designing a simple website for my football team where we can tell each other if we're able to play next weekend.

    For this website I designed a page with radio buttons with the options: Attending, Not Attending, Unknown (standard option). But i'm not sure how to save the information from the radio buttons to the database and how to extract it again.

    The code for the radio button page:
    (Just for 2 players atm, will extend when I know how to complete the whole idea):
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
     <p>Vink aan of je er bij bent of niet: </p>
     <table width="600" border="0">
       <tr>
         <th scope="col">Naam</th>
         <th scope="col">&nbsp;</th>
       </tr>
       <tr>
         <td>Ale</td>
         <td><form id="form2" name="form2" method="post" action="">
             <label>
               <input type="radio" name="Ale" value="Ja" id="Ale_0" />
               Aanwezig</label>
             <label>
               <input type="radio" name="Ale" value="Nee" id="Ale_1" />
               Afwezig</label>
             <label>
               <input type="radio" name="Ale" value="Geen" id="Ale_2" />
               Onbekend</label>
         </form></td>
       </tr>
       <tr>
         <td>Andy</td>
         <td><form id="form1" name="form1" method="post" action="">
             <label>
               <input type="radio" name="Andy" value="Ja" id="Andy_0" />
               Aanwezig</label>
             <label>
               <input type="radio" name="Andy" value="Nee" id="Andy_1" />
               Afwezig</label>
             <label>
               <input type="radio" name="Andy" value="Geen" id="Andy_2" />
               Onbekend</label>
         </form></td>
       </tr>
     </table>
     <p>&nbsp;</p>
    </body>
    </html>
    My idea was that the people can change their options, press a save button and the view for the other players will be altered accordingly. I hope this is enough information, else just ask what you need :)
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    So what are you asking? You need to be able to connect to a database using PHP and parse the data from the page and insert it into the database.

    Note, you have multiple people on the same page, what stops Ale from changing Andy's status?

    There are tutorials online if you don't know how to use PHP to insert and update records in a database.

    You'll need to know SQL as well.



    Dan

    Comment

    • Remco

      #3
      Thanks for the reply dan, I know how to use SQL, just didn't know how to combine it with php as it's my first website with php, but i've fixed it already with using lists instead of radio buttons.

      And for the multiple people on the same page, it's a page based on trust.

      Comment

      Working...