Using PHP to dump HTML table data into MYSQL Table on form submit

0 Sushant Dahal · April 10, 2015
How can I dump the values of a table in a HTML page, that has a table which has some data and some input fields that takes inputs from us, to mysql table after I press the submit button. I searched a lot but I haven't found anything useful. Can anyone help me out in this?

Post a Reply

Replies

Oldest  Newest  Rating
0 Manuel Treutlein · April 11, 2015
OK, sorry I will use the normal text field: 

Html-file(formular):
<html>
<body>
<form action="evaluation.php" method="post">
    <table>
        <tr><td>value:</td><td><input name="value"/></td></tr>
        <!-- more values possible -->
        <tr><td><input type="submit" /></td></tr>
    </table>
</form>
</body>
</html>




Php-file(evaluation.php)
<?php
    //$value = $_POST["value"]; better:
    $value = mysql_real_escape_string($_POST["value"]);
    // do the database stuff
    $con = mysqli_connect(HOST, HOSTNAME, HOSTPASSWORD);
    mysql_selected_db($con, "nameOfDatabase");
    // send the query 
    mysqli_query($con, "INSERT INTO $table(`value`, `value2`, /* ... */) VALUES ($value, 1, /* ... */)");
    // you can prove your success
    if(mysql_affected_rows($con) > 0)
        echo "successful";
    else
        echo "error";
    // close your connection 
    mysqli_close($con);
?>


I hope this answers your question. 
0 Manuel Treutlein · April 11, 2015




value:




Now the php-file(evaluation.php):


I hope I could help you. 
0 Sushant Dahal · April 11, 2015
Sir, there is nothing that is being shown in the reply. Did you mention any solution? Please check it out yourself. I cannot see any thing in the reply.
  • 1

PHP

103,491 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators