SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    table within a form

    How would I go abouut making a form like so

    EventCode StudentID Result Notes
    1 1 [textfield here] [textfield here]
    1 2 [textfield here] [textfield here]
    1 3 [textfield here] [textfield here]
    1 4 [textfield here] [textfield here]
    1 5 [textfield here] [textfield here]

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since the form itself appears to contain tabular data, I'd probably put the table inside the fieldset (after the required legend), but without seeing a graphic of what you want, I can't say for certain.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well basically I want a form that is presented as a table with some values alreay on the form and some that need to be entered (ie a textfield). Heres what I have so far:
    (By the way I am new to html so I don't know too much...)
    PHP Code:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <h1>Add Results</h1>
     
    <table border="1">
    <tr>
    <td> <strong>Student ID</strong> </td>
    <td> <strong>Student Name</strong> </td>
    <td> <strong>Result</strong> </td> 
    <td> <strong>Notes</strong> </td>
    <td> <strong>Notes</strong> </td>
    </tr>

    <?php
    //Display the contents of te events table in a table.
    while ($Students mysql_fetch_array($Student)) {
      
    $StudentID htmlspecialchars($Students['StudentID']);
      
    $FirstNames htmlspecialchars($Students['FirstNames']);
      
    $LastNames htmlspecialchars($Students['LastNames']);
        
       echo 
    "<tr>           
       <td> 
    $StudentID </td> <td> $FirstNames &nbsp $LastNames </td>           
       <td> <p> <input type=\"text\" name=\"Result\" size=\"25\"  /> </p></td>             
       <td> <p< <input type=\"text\" name=\"Notes\" size=\"25\"  /> </p> </td>            </tr>" 
    ;  
      }
     
     
    ?>   
    </table>


    <input type="submit" value="SUBMIT" />
    </form>
      
        <p><a href="results.html">Retun to results.</a></p>
        <p><a href="ardindex.html">Retun to main index.</a> </p>
          
          <?php }?>

  4. #4
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, that doesn't look too much like tabular data to me. Instead, I'd be looking at labels for the student ID, name, results, and notes, and then the inputs being associated with those labels. Of course, that would require the use of fieldsets and legends as well. I have an example of such a setup here: http://www.dan-schulz.com/temp/css-form-example/

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Na it aint really like that, its more that the lables are data pulled from a database table that have already been assigned values, what I want to do is assign values to other variables based on the values already entered in the database, if that makes any sense?

  6. #6
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It does, but you don't have to use HTML tables to display that data. You can output the database values pretty much any way you want. If I didn't know better, I'd say this was more of a PHP and MySQL issue than an HTML one.

    I know someone who's good with that stuff, I'll ask if he can help you out.

  7. #7
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    funny I was in php and they told me to go to html, I'm so confused!Can your friend help me?

  8. #8
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dan. I am still not quite clear what is it that the OP actually wants to implement (or where exactly is he having the problem) but I would make an guess.

    OP.does the following code guide you towards the right direction?
    Code PHP:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
      <h1>Add Results</h1>
      <table border="1">
        <tr>
          <td><strong>Student ID</strong> </td>
          <td><strong>Student Name</strong> </td>
          <td><strong>Result</strong> </td>
          <td><strong>Notes</strong> </td>
        </tr>
    <?php
    //Display the contents of te events table in a table.
    while ($Students = mysql_fetch_array($Student)) {
      $StudentID = htmlspecialchars($Students['StudentID']);
      $FirstNames = htmlspecialchars($Students['FirstNames']);
      $LastNames = htmlspecialchars($Students['LastNames']);
      $result = htmlspecialchars($Students['result']);
      $notes = htmlspecialchars($Students['notes']);
     ?>
     <tr>
        <td> <?php print $StudentID; ?><input type="hidden" name="id[]" value="<?php print $StudentID; ?>"></td>
        <td> <?php print "$FirstNames $LastNames"; ?></td>
        <td><input type="text" name="Result[]" value="<?php print $result; ?>" size="25"  /></td>
        <td><input type="text" name="Notes[]" value="<?php print $notes; ?>" size="25"  /></td>
    </tr>  
     <?php } ?>
      </table>
      <input type="submit" value="SUBMIT" />
    </form>
    <p><a href="results.html">Retun to results.</a></p>
    <p><a href="ardindex.html">Retun to main index.</a> </p>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •