\n"; print_r($_SESSION); echo "
\n"; echo "\$_POST
\n"; print_r($_POST); } //-------------------- // [$flag] // 1: 検索ページ初期アクセス状態 // 2: 新しいキーワードによる検索結果 // 3: リンクによる検索結果のページ移動 // 4: 商品を購入した //-------------------- $flag = 1; if (isset($_POST['send'])) { if ($_POST['send'] == 1) { $flag = 2; $page = 1; $_SESSION['cate_id'] = $_POST["cate"]; $_SESSION['item_word'] = htmlspecialchars(trim($_POST["item_word"])); $_SESSION['maker_word'] = htmlspecialchars(trim($_POST["maker_word"])); $_SESSION['serial_word'] = htmlspecialchars(trim($_POST["serial_word"])); $_SESSION['price'] = htmlspecialchars(trim($_POST["price"])); $_SESSION['highlows'] = $_POST["highlows"]; } else { $flag = 4; $page = $_GET['page']; } } else { if (isset($_GET['page']) && !empty($_GET['page'])) { $flag = 3; $page = $_GET['page']; } else { unset($_SESSION['cate_id']); unset($_SESSION['item_word']); unset($_SESSION['maker_word']); unset($_SESSION['serial_word']); unset($_SESSION['price']); unset($_SESSION['highlows']); unset($_SESSION['all_ros']); } } function exit_script($errmsg) { echo $errmsg; echo "\n"; echo "\n"; echo "\n"; end_connect($conn); exit; } ?> Unix実験[データベース] : 中村電機

中村電機

\n"; } ?>
ジャンル
商品名
メーカー・アーティスト
型番・JANコード
値段
<%TITLE%> <%PRICE%>円 <%POINT%>pt

<%ZAIKO%>
<%MAKER%> (<%NUMBER%>) (<%FIX%>)
MAIN; // DBへの接続 $conn = start_connect(); if ($flag == 1) { exit_script(""); } else if ($flag == 2) { // 入力したキーワードの該当行を抽出するSQL文の生成 $sql = make_sql($_POST['cate'], $_POST['highlows'], $_POST['item_word'], $_POST['maker_word'], $_POST['serial_word'], $_POST['price']); if ($debug) { echo $sql."
\n"; } // 仮想テーブルの生成 $all_ros = create_view($conn, $sql, $view_tbl); if($all_ros == NULL) { exit_script("fail create_view()
\n"); } $_SESSION['all_ros'] = $all_ros; $st = 1; } else { $st = ($page-1) * $max_ros + 1; } if ($_SESSION['all_ros'] > 2000) { echo "該当件数: ".$_SESSION['all_ros']."
\n"; exit_script("検索結果が500件を超えました。条件を詳しく入力し直してください"); } else if ($_SESSION['all_ros'] == 0) { exit_script("該当データがありません。条件を入力し直してください"); } //-------------------------------- // SQL文の実行 // $_SESSION['all_ros'] : 仮想テーブル全体の行数 // $ros : 返されたテーブルの行数 ($max_rowsと同値) // $res : テーブルの連想配列 //-------------------------------- list($ros,$res) = select_range_data($conn, $view_tbl, $st, $st+$max_ros-1); if ($ros == NULL) { print_r($ros); exit_script("fail select_range_data()"); } $start = ($page-1)*$max_ros+1; $end = $start + $max_ros-1; if ($end > $_SESSION['all_ros']) { $end = $_SESSION['all_ros']; } echo "$start - $end / ".$_SESSION['all_ros']."
\n"; for ($i = 0; $i < $ros; $i++) { $a = 0; reset($res); //---------------------------- // $tmp[0] = SEQ_NO // $tmp[1] = 商品番号 // $tmp[2] = 商品名 // $tmp[3] = メーカー・アーティスト // $tmp[4] = 店頭価格 // $tmp[5] = ポイント // $tmp[6] = 定価 // $tmp[7] = 型番・JANコード //---------------------------- while ($column = each($res)) { $data = $column['value']; $tmp[$a++] = $data[$i]; } if ($debug) { print_r($tmp); } // 在庫チェック $zaiko = get_zaiko($conn, $tmp[1]); if ($zaiko == NULL) { exit_script("fail get_zaiko\n"); } else if ($zaiko > 1) { $msg = "在庫有り"; if (1) { $msg .= " $zaiko"; } } else { $msg = "在庫なし"; } $out = str_replace('<%TITLE%>', $tmp[2], $main); $out = str_replace('<%PRICE%>', $tmp[4], $out); $out = str_replace('<%POINT%>', $tmp[5], $out); $out = str_replace('<%MAKER%>', $tmp[3], $out); $out = str_replace('<%NUMBER%>', $tmp[7], $out); $out = str_replace('<%FIX%>', $tmp[6], $out); $out = str_replace('<%ID%>', $tmp[1], $out); $out = str_replace('<%ITEM%>', $tmp[2], $out); $out = str_replace('<%ZAIKO%>', $msg, $out); echo $out; } echo "
\n"; // 同キーワードによる検索結果の他ページへのリンク for ($i=1; $i*$max_ros < $max_ros+$_SESSION['all_ros']; $i++) { if ($i == $page) { $next .= " $i "; } else { $next .= " $i "; } } echo "$next
"; end_connect($conn); ?>