1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| <?php
//connect to a DSN "myDSN"
// connexion à une source de données "myDSN"
$conn = odbc_connect('Driver={SQL Server};Server=localhost;Database=test','','');
if ($conn)
{
//the SQL statement that will query the database
$query = "select ncde from commande";
//perform the query
$result=odbc_exec($conn, $query);
//perform the query
$result=odbc_exec($conn, $query);
echo "<table border=\"1\"><tr>";
$colName = odbc_num_fields($result);
for ($j=1; $j<= $colName; $j++)
{
echo"<th>";
echo odbc_field_name ($result, $j );
echo"</th>";
}
//fetch tha data from the database
while(odbc_fetch_row($result))
{
echo"<tr>";
for($i=1;$i<=odbc_num_fields($result);$i++)
{
echo"<td>";
echo odbc_result($result,$i);
echo"</td>";
}
echo"</tr>";
}
echo"</td> </tr>";
echo"</table >";
//close the connection
odbc_close ($conn);
}
else
echo "odbc not connected";
?> |