Hi There,
I am using a small script that basically uses ODBC to connect to a MS SQL server...It queries the master table and gets database names and creation dates from sysdatabases. I can get it to get the results, I can have them print out via a webpage. My problem is that I am trying to throw it into a table so that it is easier to view. It prints out the table, but I want to include a header that says Database Name and Create date. When the table prints out, it prints out the Label row, then the 1st results from the db, then it prints the Label row again and then the 2nd row of results and on and on. I want it to only print the labels once, and list all of the database one after another.
Can anyone help, I am soooo lost?
TIA, celtica
Here is the code I am using:
<?
$connect = odbc_connect("ODBC DSN", "UNAME", "PW");
# query the users table for name and surname
$query = "select a.[name], a.crdate from sysdatabases as a where a.[name] LIKE 'CSL_' +'%' and a.[name] NOT LIKE '%' + '_DA'";
# perform the query
$result = odbc_exec($connect, $query);
# fetch the data from the database
while(odbc_fetch_row($result)){
$dbname = odbc_result($result, 1);
$createdate = odbc_result($result, 2);
print("<table border=1 cellspacing=0 cellpadding=0><tr><th>DBName</th><th>CreateDate</th></tr><tr><td>$dbname</td><td>$createdate</td></tr></table>");}
# close the connection
odbc_close($connect);
?>