Menu
Hello,
I am making a program using html to help a company standardize its procedures. I have made a form in html that is made up of 9 tables. The user enters the data in these tables and then clicks the submit button.
Now what I want to do, is have the entered data appear in one big table on the same ‘web’ page. Basically everything entered in the small tables is then transferred to one big table after clicking submit… if that makes sense.
How do I do that? Do I have to mess with ‘action’ in form method or design another html program?
Thanks,
Michael
[code=php]<?php
if (isset($_POST['submit'])){
echo "<table>";
echo "<tr>";
echo "<td>" . $_POST['field_1'] . "</td>";
echo "</tr>";
}
else{
echo "<p>No submission has taken place</p>";
?>
}[/code]
[CODE]<form method="post" action="result.php">[/CODE]
[code=php]<?php
if(isset($_POST['submit'])){
//grab the values from the post collection
$FirstName=$_POST['firstname'];
$LastName=$_POST['lastname'];
$Comments=$_POST['comments'];
//insert the values into the database table
$sql="INSERT INTO MyTable (FName
,LName
,Comments
)VALUES('$FirstName', '$LastName', '$Comments')";
//check to see if the query is successful and move to result page if it is
if(@mysql_query($sql){
Location("http://www.somedomain.com/result.php");
}
else{
echo "An error has occurred";
}
?>[/code]
[code=php]<?php
//create connection to the database server
$dbconn=mysql_connect("username", "password") or die("Can't connect to the database") . mysql_error());
//select the database to use
$db=mysql_select_db("yourdatabase");
//create sql query to extract values
$sql="SELECT * FROM My_Table";
//assign the results of $sql to associative array
$result=mysql_result($sql);
//loop through the result set
while($row=mysql_fetch_array($result)){
//grab each insert value and place in row variable
$FirstName=$row["FName"];
$LastName=$row["LName"];
$Email=$row["Email"];
//build the output table
echo "<table>";
echo "<tr>";
echo "<td>". $FirstName . "</td>";
echo "<td>". $LastName . "</td>";
echo "<td>". $EmailName . "</td>";
}
?>[/code]
result.php
I am having problems implementing the code written above. What do you mean by having a php file called form.php inside the original form?
Do you mean putting the code you suggested before the doctype or put it in a separate file called form.php that I create in Notepad?
[/quote]
I have been reading some textbooks and it says I need to create an SQL table, Do you know how to do that and is it required?
[/quote]
I would just like to clarify that this is not an internet application and will be used internally by only one computer at a time.
If it is not an online form per se do I need to have a database server? How do I get one?
[/quote]
After the user has filled in the table and clicks submit, do I need an intermediate stage that processes the data and then puts it into a new table?
[/quote]
Does the actionfile have to be in the same directory as my original form file? This is because I am only dealing with files that I execute from my computer and nothing to do with the internet. result.php
[/quote]
Again sorry for these simple questions[/quote]
0.1.9 — BETA 5.18