I am trying to save lots of variables to a database and it is getting ridiculous now. I am using PHP and MySQL.
Is there a way, I can get the array value and the array keys (array keys are exactly the same as the table column/field names) in one go without having to add a new variable and table column pair.
To be honest, I just need help with constructing the SQL String only, the rest is setup for me.
I can add the new column to the database table when I have to store a new variable.
Thanks all for any help
If you want to create a SQL query from your array, this might help:
In this case, the query would look something like this:
If you have a multidimensional array (an array of arrays) you can create a query as follows:
And in this case, the resulting query would be something like this:
Now only thing you have to worry about is creating the corresponding columns to the database.