I have a bit of code I use to print each variable I pass through a form to a processing script.
I have a database with the identical naming conventions and I want to post each variable. I know this has some security implications but it is the most practical solution given the amount of variables I have to pass.
This is my current script..
<?php
printArray($_POST);
function printArray($array){
foreach ($array as $key => $value){
echo "$key => $value" . "<br>";
if(is_array($value)){ //If $value is an array, print it as well!
printArray($value);
}
}
}
?>
I know I can do something like this..
<?php
printArray($_POST);
$sql = "INSERT INTO (applications) VALUES (";
function printArray($array){
foreach ($array as $key => $value){
$sql .= "'" . $key."'";
echo $sql;
if(is_array($value)){ //If $value is an array, print it as well!
printArray($value);
}
}
}
?>
Is there an easier way to do this?
something like this might work for you.
while( ($sql = your_filter_function(array_shift($_POST)) ) != NULL)
{
//do sql stuff here
}
Sorry for the lack of depth I am on mobile