2026, 새로운 도약을 시작합니다.

안녕하세요 sql 공부중인 사람인데 궁금한점이 생겨서 문의드립니다. 채택완료

<?php
ob_start();
include_once($_SERVER['DOCUMENT_ROOT'] ."/common.php");
$is_title="";


$sql="select * from g5_member";
$result=sql_query($sql);
?>
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<style type="text/css">
</style>
<title>회원내역</title>
</head>
<body>
<table>
<tr>
<th scope="col">회원아이디</th>
<th scope="col">이름</th>
<th scope="col">연락처</th>
<th scope="col">포인트</th>
<th scope="col">출신학교</th>
<th scope="col">포인트총합계</th>
</tr>
 <?php
        for ($i=0; $list = sql_fetch_array($result); $i++) {
         ?>
<tr>
<td class='txt'><?php echo $list['mb_id']?></td>
<td class='txt'><?php echo $list['mb_name']?></td>
<td class='txt'><?php echo $list['mb_hp']?></td>
<td class='txt'><?php echo $list['mb_point']?></td>
<td class='txt'><?php echo $list['mb_1']?></td>
</tr>
<?php }?>
</table>
</body>
</html>

이런식으로 짰는데,

여기서 mb_1 값에 서울대학교, 연세대학교가있을때

검색기능을 넣어서 서울대학교만 검색을 하려고 합니다.

어떻게 해야할까요?

답변 3개

select sum(mb_point) from g5_member where mb_1 ='서울대학교' 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

아그리고 서울대학교를 검색했을때, 서울대학교를 선택한 사람들의 포인트 총계도 구하려고 하는데 어렵습니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

$sql="select * from g5_member where mb_1 ='서울대학교' ";

$sql="select * from g5_member where mb_1 like '%서울%' ";

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

이걸 검색해서 찾을수있게 넣고 싶어서요

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고