/ Published in: PHP
This generates a simple insert statement for mysql based on all the variables in $_GET or $_POST using a simple page. It does not do the inserts although that is a simple addition - just builds and displays your insert statement.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $fields = ''; $values = ''; $sql = display_post_get(); echo "<br>strSQL:<br>" . $sql; function display_post_get() { if ($_POST) { $fields .= $result_nme . "," ; $values .= $result_val . "','" ; } echo "Fields: " . $fields; echo "Values: " . $values . "<p />"; $strSQL = "Insert into YOURDB ($fields) VALUES ('$values)"; return $strSQL; } if ($_GET) { $fields .= $result_nme . "," ; $values .= $result_val . "','" ; } echo "Fields: " . $fields; echo "Values: " . $values . "<p />"; $strSQL = "Insert into YOURDB ($fields) VALUES ('$values)"; return $strSQL; } } ?>