I am using a query to get all the column names from my database, then I am trying to display the results comma seperated, in quotation marks and in (). And also make variables out of them.(Take a look at the example at the bottom and you will probably understand) The Columns I have in my DB are:
ID
Naam
Email
Soort
Status
And I am using this to get them:
$strSQL = "select column_name from information_schema.columns where table_name='Klant'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
So I was wondering If there is any way to get the result displayed like this:
$vaaw = array("(ID)", "(Naam)", "(Email)", "(Soort)", "(Status)");
And also like this:
$vervang = array("$ID", "$Naam", "$Email","$Soort", "$Status");
I want to use this instead of typing the column names in my code because if I ever change the column name or add/delete a column then I will have to edit the codes again.
I have been looking for a way to get this for hours now but I just can't find anything to display it like this. I think it could be possible using the implode
function but I couldn't find anything like this. I hope my question is clear but if not just ask for clarification!
Also, I know I shouldn't be using Mysql_ anymore but I am working on that and will change to PDO soon!