lets say i have a big form and the sql query to enter it into the database would be too long and time consuming to do,
would this be possible?
$num = 0;
$sql .= "INSERT INTO $tablename (";
while ($_POST) {
$var = $_POST['$num'];
$sql .= "$var, ";
$num++;
}
$sql = str_replace(strrchr($sql,", "),"",$sql);//gets rid of the extra comma and space at the end
$sql .= ") VALUES (";
$num = 0;
while ($_POST) {
$var = $_POST['$num'];
$sql .= "'$".$var."', ";
}
$sql = str_replace(strrchr($sql,"', "),"",$sql);//gets rid of the extra comma and space at the end
$sql .= ")";
should output:
INSERT INTO $tablename (var1, var2, var3) VALUES ('$var1', '$var2', '$var3')