셀렉트박스로 리스트 표시
본문
<?php
//db연결
$connect = mysqli_connect("localhost", "uksoft", "ghkdskacjf123","uksoft");
$query = "SELECT * FROM market";
$result = mysqli_query($connect, $query);
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
</br></br>
<div class="container" style = "width:100%;">
<h3 align="center">고고기획 시장 현황</h3>
<br>
<div class="talbe-responsive">
<!-- 추가 버튼-->
<div align="right">
<button type="button" name="add" id="add" data-toggle="modal"
data-target="#add_data_Modal" class="btn btn-success">추가</button>
</div>
<br>
<div id="employee_table">
<table class="table table-bordered">
<tr>
<th width="15%">시장명</th>
<th width="15%">가맹점명</th>
<th width="50%">주소</th>
<th width="15%">보기</th>
</tr>
<?php
while($row=mysqli_fetch_array($result))
{
?>
<tr>
<td><?php echo $row["시장명"]; ?> </td>
<td><?php echo $row["가맹점명"]; ?> </td>
<td><?php echo $row["주소"]; ?> </td>
<td><button type="button" onclick="location.href='https://m.map.naver.com/search2/search.naver?query=<?php echo $row["주소"]; ?>&siteLocation=&queryRank=&type='" class="edit_data btn btn-warning" />지도</button></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<div>
</body>
</html>
시장별로 리스트를 노출 하고 싶은데 어떻게 해야할까요?
!-->답변 1
<?php
//db연결
$connect = mysqli_connect("localhost", "uksoft", "ghkdskacjf123","uksoft");
$query = "SELECT * FROM market";
if($sh_market) $query .= " where 시장명='$sh_market' ";
$result = mysqli_query($connect, $query);
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
</br></br>
<div class="container" style = "width:100%;">
<h3 align="center">고고기획 시장 현황</h3>
<br>
<form name="fsearch" method="get" action="<?php $_SERVER['PHP_SELF']?>">
<div>
시장 검색 : <select name="sh_market" onchange="this.form.submit()">
<?php
$que = "SELECT 시장명 from market group by 시장명";
$sql = mysqli_query($connect, $que);
while($row=mysqli_fetch_array($result)) {
?>
<option value="<?php echo $row['시장명']?>"<?php if($sh_market == $row['시장명']) echo" selected";?>><?php echo $row['시장명']?></option>
<?php } ?>
</select>
</div>
</form>
<div class="talbe-responsive">
<!-- 추가 버튼-->
<div align="right">
<button type="button" name="add" id="add" data-toggle="modal"
data-target="#add_data_Modal" class="btn btn-success">추가</button>
</div>
<br>
<div id="employee_table">
<table class="table table-bordered">
<tr>
<th width="15%">시장명</th>
<th width="15%">가맹점명</th>
<th width="50%">주소</th>
<th width="15%">보기</th>
</tr>
<?php
while($row=mysqli_fetch_array($result))
{
?>
<tr>
<td><?php echo $row["시장명"]; ?> </td>
<td><?php echo $row["가맹점명"]; ?> </td>
<td><?php echo $row["주소"]; ?> </td>
<td><button type="button" onclick="location.href='https://m.map.naver.com/search2/search.naver?query=<?php echo $row["주소"]; ?>&siteLocation=&queryRank=&type='" class="edit_data btn btn-warning" />지도</button></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<div>
</body>
</html>
답변을 작성하시기 전에 로그인 해주세요.