Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title></title>
- </head>
- <body>
- <?php
- $data_source='SQLSERVER2008EXAMPLES';
- $user='sa';
- $password='testing123';
- // connect to the SQL server using username and password
- $conn=odbc_connect($data_source,$user,$password);
- if (!$conn){ //checking if connection is established
- if (phpversion() < '4.0'){
- exit("Connection Failed:" . $php_errormsg );
- }
- else{
- exit("Connection Failed:" . odbc_errormsg() );
- }
- }
- // here we can put our query
- $query="select sr.name, sr.phone from Sales_Rep sr, Car c where sr.name = c.seller and c.color = 'green';";
- //execute the query
- $result=odbc_exec($conn,$query);
- // check for an error
- if (!$result){echo "Problem with query";}
- //fetch the result and show it in the loop to the table
- echo "<table>";
- while (odbc_fetch_row($result)){
- $col1=odbc_result($result, "name");
- $col2=odbc_result($result, "phone");
- echo "<tr>";
- echo "<td>$col1</td>";
- echo "<td>$col2</td>";
- echo "</tr>";
- }
- echo "</table>";
- // Disconnect from the database
- odbc_close($conn);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement