Hi all...
I'm trying to create a simple HTML table generated by php from mySQL table. This table simply displays the First Name and Last Name of all Employees in the database table.
The trick is, I would also like to generate an HTML FORM, so beside each first and last name, there is a button that submits the first and last name to another php processing page.
Can this be done?
<?php
//Establish Connection String
$con = mysql_connect("DOMAIN","USERNAME","PASSWORD");
//Connect to database
mysql_select_db("DATABASE", $con);
//Query database and set result to variable
$result = mysql_query("SELECT * FROM cls_app_form");
//Close Connection
mysql_close($con);
//Establish Table Header
echo "<thead><tr> <th>First Name</th> <th>Last Name</th> <th>Go to Employee Application Form</th></tr></thead>";
//Set Form Name
$FormName = 0;
//Loop through table data
while($row = mysql_fetch_array($result))
{
//Set variables based on row
$FirstName = $row ['FirstName'];
$LastName = $row ['LastName'];
$FormName = $FormName++;
//Create Table
echo TABLE HEADER STUFF;
echo "<tr>";
echo "<td>"$row['FirstName'] . "</td><br />";
echo "<td>"$row['LastName'] . "</td><br />";
echo "<td>"SUBMIT BUTTON with $FirstName and $LastName submitted to another process.php page"</td>";
echo "</tr>;
}
?>
The Logic:
echo TABLE HEADER STUFF;
echo " <form id="$FormName" method="post" action="fetch.php"><tr>";
echo "<td>"$row . "</td><br />";
echo "<td>"$row . "</td><br />";
echo "<td>"<input type=submit value='Fetch Employee Application'>"</td>";
echo "</tr></form>;