1,105,320 Community Members

Combobox with mssql connection

Member Avatar
Xaelian
Newbie Poster
2 posts since May 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Member Avatar
vibhaJ
Posting Shark
960 posts since Apr 2010
Reputation Points: 126 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 3 [?]
 
0
 
Member Avatar
Xaelian
Newbie Poster
2 posts since May 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
<?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.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: