require('./lib.php');
mb_http_output('SJIS');
mb_internal_encoding('SJIS');
header('Content-type: text/html; charset=Shift_JIS');
#ini_set('session.use_cookies', 0);
#session_cache_limiter('nocache');
session_start();
$PMakerCode = $_REQUEST['MakerCode'];
$PCarCode = $_REQUEST['CarCode'];
$PCategoryCode = $_REQUEST['CategoryCode'];
$PKeyword = $_REQUEST['Keyword'];
$Page = $_REQUEST['Page'];
$SID = $_REQUEST['SID'];
$RecPerPage = 6; #1ページあたりの表示件数
if(!$Page) $Page = 1;
$Keyword = str_replace(',',',',$Keyword);
$Keyword = str_replace('/' ,',',$Keyword);
$Keyword = str_replace('/',',',$Keyword);
$Keyword = str_replace(' ' ,',',$Keyword);
$Keyword = str_replace(' ',',',$Keyword);
$Keyword_UTF = $Keyword;
#---データベースに接続する
require("config.php");
$con =mysql_connect(HOST,USER,PASS)
or die("接続できません");
$result1 = mysql_select_db(DBNAME,$con)
or die("データベースがありません");
#---商品テーブルから指定された検索条件に合致するデータを読み込む
$syohin = array();
$sql = "SELECT SyohinNo, MakerCode, MakerName, CarCode, CarName, SyohinName, Kakaku, Photo1 FROM t_syohin ";
$where = "";
if($PMakerCode){
$PMakerCode = str_pad($_REQUEST['MakerCode'],3,0,STR_PAD_LEFT);
$where = $where . "MakerCode = '" . $PMakerCode . "' ";
}
if($PCarCode){
if($where){$where = $where . "AND ";}
$where = $where . "CarCode = '" . $PCarCode . "' ";
}
if($PCategoryCode){
if($where){$where = $where . "AND ";}
$where = $where . "(Catgry1Code = '" . $PCategoryCode . "' ";
$where = $where . "OR ";
$where = $where . "Catgry2Code = '" . $PCategoryCode . "') ";
}
if($PKeyword){
$PKeyword = mb_convert_encoding($PKeyword,'EUC-JP','SJIS');
if($where){$where = $where . "AND ";}
$where = $where . "(SyohinName LIKE '%" . $PKeyword . "%'";
$where = $where . "OR ";
$where = $where . " CarName = '%" . $PKeyword . "%'";
$where = $where . "OR ";
$where = $where . " Setumei = '%" . $PKeyword . "%')";
}
if($where){$sql = $sql . "WHERE " . $where;}
$result = mysql_query($sql,$con);
$syohin_max = mysql_num_rows($result);
while($row = mysql_fetch_assoc($result))
{
$SyohinNo = $row[SyohinNo];
$SyohinName = mb_convert_encoding($row[SyohinName],'SJIS','EUC-JP');
$MakerCode = $row[MakerCode];
$MakerName = mb_convert_encoding($row[MakerName],'SJIS','EUC-JP');
$CarCode = $row[CarCode];
$CarName = mb_convert_encoding($row[CarName],'SJIS','EUC-JP');
$Kakaku = $row[Kakaku];
$Photo1 = $row[Photo1];
array_push($syohin,compact('SyohinNo','SyohinName','MakerCode','MakerName','CarCode','CarName','Kakaku','Photo1'));
}
#---パラメータの名称を取得する
if($PMakerCode){
$sql = "SELECT MakerName FROM m_maker ";
$sql = $sql . "WHERE MakerCode = '" . $PMakerCode . "'";
$result = mysql_query($sql,$con);
$row = mysql_fetch_assoc($result);
$PMakerName = mb_convert_encoding($row[MakerName],'SJIS','EUC-JP');
}
if($PCarCode){
$sql = "SELECT CarName FROM m_car ";
$sql = $sql . "WHERE MakerCode = '" . $PMakerCode . "' ";
$sql = $sql . "AND CarCode = '" . $PCarCode . "' ";
$result = mysql_query($sql,$con);
$row = mysql_fetch_assoc($result);
$PCarName = mb_convert_encoding($row[CarName],'SJIS','EUC-JP');
}
if($PCategoryCode){
$sql = "SELECT CategoryName FROM m_category ";
$sql = $sql . "WHERE CategoryCode = '" . $PCategoryCode . "' ";
$result = mysql_query($sql,$con);
$row = mysql_fetch_assoc($result);
$PCategoryName = mb_convert_encoding($row[CategoryName],'SJIS','EUC-JP');
}
mysql_close($con);
#-----ページ表示用開始レコードと終了レコード計算 -----------------
$s_rec = ($Page-1) * $RecPerPage;
$e_rec = $s_rec + $RecPerPage - 1;
if($e_rec >= $syohin_max) $e_rec = $syohin_max - 1;
$maxpage = (int)($syohin_max / $RecPerPage);
if($maxpage * $rec_p_page < $syohin_max) $maxpage++;
if($Page > $maxpage) $Page = $maxpage;
?>
検索商品一覧
if($syohin_max == 0){
echo "";
}
?>
|
|
|
検索商品一覧
if($PMakerCode){ ?>
メーカー: echo $PMakerName;?>
}else{ ?>
メーカー:指定なし
} ?>
if($PCarCode){ ?>
車種: echo $PCarName;?>
}else{ ?>
車種:指定なし
} ?>
if($PCategoryCode){ ?>
パーツカテゴリー: echo $PCategoryName;?>
}else{ ?>
パーツカテゴリー:指定なし
} ?>
if($PKeyword){ ?>
キーワード: echo $PKeyword;?>
}else{ ?>
キーワード:指定なし
} ?>
|
|
[
if($Page > 9){ ?>
<< /
} ?>
$s = $Page - 4;
$e = $Page + 4;
if($s < 1){
$s = 1;
$e = 9;
}
if($e > $maxpage) $e = $maxpage;
for($i = $s ; $i <= $e ; $i++){?>
if($i != $s){ ?>/ } ?>
if($i == $Page){?>
echo $i;?>
}else{ ?>
echo $i;?>
} ?>
} ?>
if($e < $maxpage){ ?>
/ >>
} ?>
] |
|
写真 |
車種 |
商品名 |
価格 |
詳細 |
for($i=$s_rec;$i<=$e_rec;$i++){ ?>
if($syohin[$i]['Photo1'] && file_exists('../parts_img/' . $syohin[$i]['Photo1'])){?>
}else{ ?>
} ?>
|
echo $syohin[$i]['CarName'];?> |
echo $syohin[$i]['SyohinName'];?> |
\ echo number_format($syohin[$i]['Kakaku']);?>
(税込\ echo number_format((int)($syohin[$i]['Kakaku']*1.05+0.5));?>)
|
詳細
|
|
} ?>
|
|
[
if($Page > 9){ ?>
<< /
} ?>
$s = $Page - 4;
$e = $Page + 4;
if($s < 1){
$s = 1;
$e = 9;
}
if($e > $maxpage) $e = $maxpage;
for($i = $s ; $i <= $e ; $i++){?>
if($i != $s){ ?>/ } ?>
if($i == $Page){?>
echo $i;?>
}else{ ?>
echo $i;?>
} ?>
} ?>
if($e < $maxpage){ ?>
/ >>
} ?>
] |
|
[ 検索トップページへ戻る ] |
|
|
|
|