|
-
May 6th, 2002, 05:47 AM
#1
Thread Starter
Lively Member
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"

-
May 6th, 2002, 08:37 AM
#2
PowerPoster
?
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.
-
May 6th, 2002, 09:56 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|