Greetings:
I'm in the process of creating a number of "add/edit" forms and scripts to a site I'm working on. For each of these, the list of variables to be placed into the "INSERT..." statements was pretty long, so I'm using a trick from my days futzing with Crystal Reports and SQLServer.
The trick is that I have an SQL table called "tblTables" which holds metadata about the tables: "friendly names" for column headers, "sort order" for display and "access level" to hide some columns from users without proper security.
The idea is that when I need to do SELECTs off of the tables, I can write a single query to pull the fieldnames appropriate to the user's security level, pull the column headers for the resultant table when ready to display the result, and pull the data itself.
So this is what I have:
$tbl_fields = mysql_query("Select tblFieldName from tblTables where tblNumber=2 AND tblGroup=$Permissions") //$Permissions is a session variable from User Login;
What I want to do is take the result of this query, and implode() it with ", " as the glue to fit it in the select list of the query that pulls the data.
I tried using
array_push()
while looping my way through the result set, but I keep getting a zero-element array as a result. Is there a better way to take an SQL result set and implode it for use as a string?
:: Note: I did check the session vars, table permissions and directly querying the db, but everything checked out. I get results when I simply list out the result set, but nothing's making its way into the array I want to implode. jkc
Thanks in advance for any assistance.