/    Sign up×
Community /Pin to ProfileBookmark

PHP to generate an HTML FORM

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?

eg.

//Connect to database
mysql_select_db(“cls_1”, $con);

//Query database and set result to variable
$result = mysql_query(“SELECT * FROM cls_app_form”);

//Close Connection
mysql_close($con);

//Generate Table
while($row = mysql_fetch_array($result))
{
echo “<td>”$row[‘FirstName’] . ” ” . $row[‘LastName’] *PUT FORM BUTTON HERE!”</td>”;
echo “<br />”;
}

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@mortyBoxauthorMar 10.2012 — **EDIT** Sorry... THIS is what I'm trying to achieve.

eg.

//Connect to database

mysql_select_db("cls_1", $con);

//Query database and set result to variable

$result = mysql_query("SELECT * FROM cls_app_form");

//Close Connection

mysql_close($con);

//Generate Table

while($row = mysql_fetch_array($result))

{

$FirstName = $row ['FirstName'];

$LastName = $row ['LastName'];


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><br />";

echo "</tr>
Copy linkTweet thisAlerts:
@ZeratulsDomainMar 10.2012 — well you could always send them with GET method instead of making a form for a POST var...

example:
[code=php]
echo "<tr>"
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo('<td><a href="myProcessingPage.php?firstName=' . $row['FirstName'] . '&lastName=' . $row['LastName'] . '">Submit</a></td>');
echo "</tr>"[/code]
Copy linkTweet thisAlerts:
@hastxMar 12.2012 — This can be done with only a few lines of code if you use this class:

ArrayQry

It would support passing the db result via the GET params as suggested by ZeratulsDomain. just check the documentation examples for outputting result to a table.
×

Success!

Help @mortyBox spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...