Esempio n. 1
0
 /**
  * select database
  * @param string db name
  * @return boolean Success: true, Fail: false
  */
 function select_db($dbname)
 {
     return @sqlsrv_select_db($dbname, $this->conn);
 }
 /**
  * Select database
  *
  * @param   string db name of database to select
  * @return  bool success
  * @throws  rdbms.SQLStatementFailedException
  */
 public function selectdb($db)
 {
     if (!sqlsrv_select_db($db, $this->handle)) {
         throw new SQLStatementFailedException('Cannot select database: ' . $this->errors(), 'use ' . $db, current(sqlsrv_fetch_row(sqlsrv_query('select @@error', $this->handle))));
     }
     return TRUE;
 }
if ($q == "word") {
    sqlsrv_select_db($con, "!1Elcwebapp");
    $sql = "SELECT * FROM word";
    $result = sqlsrv_query($con, $sql);
    echo "<center>{$q} Table</center>";
    echo "<table>\n<tr>\n<th>word_id</th>\n<th>word_name</th>\n</tr>";
    while ($row = sqlsrv_fetch_array($result)) {
        echo "<tr>";
        echo "<td>" . $row['word_id'] . "</td>";
        echo "<td>" . $row['word_name'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
}
if ($q == "level") {
    sqlsrv_select_db($con, "!1Elcwebapp");
    $sql = "SELECT * FROM level";
    $result = sqlsrv_query($con, $sql);
    echo "<center>{$q} Table</center>";
    echo "<table>\n<tr>\n<th>Level</th>\n<th>Level Description</th>\n</tr>";
    while ($row = sqlsrv_fetch_array($result)) {
        echo "<tr>";
        echo "<td>" . $row['Level'] . "</td>";
        echo "<td>" . $row['Level Description'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
}
sqlsrv_close($con);
?>
</body>