I'm making a PHP script for controlling my mssql databases. But I ran into a couple of problems.

The first problem is that I want to make a combobox out of all the databases in my microsoft SQL server. The following SQL syntax gives the results that I'm looking for, but I don't know how to place it into a combobox.

SELECT name from sys.databases where owner_sid != 0x01

My next problem is, that I have to run follwing SQL command:

RESTORE FILELISTONLY FROM DISK = 'C:\Databases\Breda\backup\Backup.BAK'

But I need to get the first column of every row, and place that in 2 variables, but I don't know how to do that.

Can anyone provide me this code?

<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include('adodb/adodb.inc.php');

$db = ADONewConnection(mssql_n);
$db->Connect('172.16.100.78', 'sa', 'SAPB1Admin');

$query ="SELECT name from sys.databases";
$result = @mssql_query($query);

echo "<select name='database'><option value='default'>Choose a database</option>";
while ($row=mssql_fetch_array($result))
{
$uid=$row['name'];

echo "<option value='" . $uid . "'>""</option>";
}
echo "</select>";


?>

This is the code I wrote for my combobox, but when I run it, it doesn't give any output.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.