Don't like ads? PRO users don't see any ads ;-)
Guest

Code

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.87 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. if( $connect === false )
  2. {
  3.   echo "Could not connect.\n";
  4.   die( print_r( sqlsrv_errors(), true));
  5. }
  6.  
  7. /* Select Statement */
  8. $select = "SELECT TOP(5)name, lv FROM Character WHERE lv > 0 AND name NOT LIKE '%@%' AND name NOT LIKE '%[GM]%'
  9. AND name NOT LIKE '%[GA]%' AND name NOT LIKE '%[DEV]%' ORDER BY lv DESC ";
  10.  
  11. /* Execute the query. */
  12. $query = sqlsrv_query( $connect, $select);
  13.  
  14. if ( $query )
  15. {
  16. }
  17. else
  18. {
  19.   echo "Error in statement execution.\n";
  20.   die( print_r( sqlsrv_errors(), true));
  21. }
  22.  
  23. /* Iterate through the result set printing a row of data upon each
  24. iteration.*/
  25. while( $row = sqlsrv_fetch_array( $query, SQLSRV_FETCH_NUMERIC))
  26. {
  27.  echo "<b>Name</b>: &nbsp;".$row[0]." <br/>";
  28.  echo "<b>Level</b>: &nbsp;".$row[1]."<br/>";
  29.  echo "<br/>";
  30.  
  31. }
  32.  
  33. /* Free statement and connection resources. */
  34. sqlsrv_free_stmt( $query);
  35. sqlsrv_close( $connect);
  36. ?>