<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=sjis">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<link rel="stylesheet" type="text/css" href="style.css">
<title>4-1-1 商品テーブルの内容をすべて表示</title>
</head>
<body>
<h2>4-1-1 商品テーブルの内容をすべて表示</h2>
<p></p>
<form>
<input type="button" value=" 戻る " onClick="history.back()">
</form>
<p></p>
<table border="1">
<tr>
<th>連番</th>
<th>会社名</th>
<th>商品コード</th>
<th>商品名</th>
<th>略称</th>
<th>仕入単価</th>
<th>売上単価</th>
</tr>
<?php
$DSN = 'drinks'; //データソース名
$DBUSER = 'root'; //ログインユーザー名
$DBPASSWORD = '*****'; //パスワード
//データベースに接続
if (! $con = odbc_connect($DSN, $DBUSER, $DBPASSWORD)) {
exit("データベースに接続できませんでした!");
}
//SQLを組み立て
$sql = 'SELECT * FROM goods';
//結果セットを取得
$rst = odbc_exec($con, $sql);
//結果セットからデータをループで読み込み
while (odbc_fetch_row($rst)) {
echo '<tr>';
echo '<td>'.odbc_result($rst, "renban").'</td>';
echo '<td>'.odbc_result($rst, "com").'</td>';
echo '<td>'.odbc_result($rst, "code1").'</td>';
echo '<td>'.odbc_result($rst, "name1").'</td>';
echo '<td>'.odbc_result($rst, "name2").'</td>';
echo '<td>'.odbc_result($rst, "sitan").'</td>';
echo '<td>'.odbc_result($rst, "uritan").'</td>';
echo '</tr>';
}
//ODBCとの接続を解除
odbc_close($con);
?>
</table>
</body>
</html>