I am trying to pull Headers from an Access table to propogate a dropdown box. I currently connect with ODBC connection. How can I get the table header names? Do I have to switch to ADO? Or is there a simple SQL statement that can pull headers as a table property?
Basically i need to pull the field names... The field titles... The things at the top of the table that describe the fields. I need them so when someone chooses them in the drop down box, my SQL statement will use the fields selected. But i need to pull them from the table because they will be changed frequently and I dont want to hardcode them.
if you have done a rowfetching query you get the column names as the non-numeric keys of the associative array returned by odbc_fetch_array(), or if you are fetching one column at the time there is odbc_field_name ();
If you have not done a query you can use odbc_columns ()
Doing it with a query I don't know Bill Gates SQL very well, for mysql it would be doable with DESCRIBE table
Using the odbc_field_name I was able to pull what I wanted. But being able to pull into an array directly would be even better. How would I word the odbc_fetch_array command to pull the Field Names right into the array? Again thanks, and if I have misunderstood the fetch array function then nevermind. I have what i need!
Here is what I did:
<?php
$conn = odbc_connect("2003","***","***")
or die("Could not connect");
$query = "SELECT * FROM tblPers";
$result = odbc_exec($conn, $query) or die('Select failed!');
$i = 0;
$fCount = odbc_num_fields($result);
odbc_fetch_array was added in PHP 4.0.2, what version are you running? (use phpinfo(); to find out)
It is not an errortrapper, it is an odbc function that will output the ODBC's last error message, I actually spelled it wrong, it is odbc_errormsg(), has been in existence since PHP 4.0.5
if odbc_connect () works it should be enabled (?) Check phpinfo() for odbc info, perhaps there are some differences with the bill gates version of php? I don't know really..