Results 1 to 3 of 3

Thread: Newbie: Subform help in PHP+MySQL

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94

    Unhappy Newbie: Subform help in PHP+MySQL

    I'm desperate.

    I can't find any info on making a subform in php (not even asp).

    I have an access database that uses subforms. However i need to import this to my mysql database. I'd like to rebuild the online input form but i don't know where to start. It needs to display the data using subforms plus i need to be able to input data using subform.

    The database looks like this (this is a small example).
    Mainform: date, dateid, location
    Subform: dateid, team1, team2, result
    the dateid field is "joined"

    Can anyone tell me where i can find more info on making subforms with php ?
    "Against All Odds"

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    ?

    subforms are a feature of the Access UI, they don't store the data and moreover that kind of feature is impossible using a server side scripting language.

    mysql just holds data, nothing else. If you have an access table, then you can recreate that as a mysql table quite easily. Anything else in an Access database is specific to Access.

  3. #3
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    You could make a PHP script, that shows only 1 record from the main table, and all coresponding records from the sub table:
    PHP Code:
    <html><body>
    <?php
    if (!isset($dateid)){
        echo 
    "ERROR, provide a dateid";
    }else{
        
    $db mysql_connect();
        
    // Query for records in main and sub tables
        
    $main_result mysql_query("SELECT * FROM maintable WHERE dateid = $dateid;"$db);
        
    $sub_result mysql_query("SELECT * FROM subtable WHERE dateid = $dateid;"$db);
        
    $main mysql_fetch_object ($main_result);
        
    // output the 1 record from the main table
        
    echo "dateid = $dateid<br>";
        echo 
    "main.date = " main.date "<br>";
        echo 
    "main.location = " main.location "<br>";
        
    // header for records from sub table
        
    echo "<table><tr><th>sub.team1</th><th>sub.team2</th><th>sub.result</th></tr>"
        
    // output all records from the sub table
        
    while ($sub mysql_fetch_object($sub_result)){
            echo 
    "<tr><td>" sub.team1 "</td>";
            echo 
    "<td>" sub.team2 "</td>";
            echo 
    "<td>" sub.result "</td></tr>";
        }
        echo 
    "</table>"
    }
    ?>
    </body></html>
    This is only for output, but I think you can do something similair with input boxes. You can make it display one extra row in the sub table, so you can enter new records. You would however need to reload the entire page after entering each record.

Posting Permissions

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



Click Here to Expand Forum to Full Width