티스토리 뷰
(2021.08.20 본인 네이버 블로그에서 작성한 글 옮겨옴)
8월 6일에 썼지만
8월 20일에 올리는 지옥의 갤러리 만들기
^_^;;;;;;;;
퇴근 1시간59분 전
째깍째깍,,,,,,,,,,,,,,,,,,,,,,,
오늘의 결과물 스포
현재 기준 이전달을 누르면 7월의 사진이 뜨고 , 또 이전달을 누르면 6월달이 나오고 ,,,,,
이렇게 달력에서처럼 바로 이전달꺼 누르고 다음달꺼 누르고 그런식...!
1. 갤러리 테이블 상태
현재 : 8월 기준으로
- 7월달꺼 (이전달)
- 다음달 (다음달 사진은 아직 없기때문에 눌러도 뜨지않음)
- 1~6월도 강제로 넣을 예정
2. img_select(test).class
<?
class select_img {
/* DB 접속 정보 */
var $host = 'localhost'; // 데이터베이스 서버 주소
var $myUser = 'jeongeum'; // 데이터베이스 사용자 ID
var $myPw = '1202'; // 데이터베이스 사용자 PASSWD
var $myDb = 'test_db'; // 데이터베이스 명
var $path;
var $name;
var $aa = "";
var $conn;
var $sql;
var $result;
function select() {
$this->conn = mysqli_connect($this->host, $this->myUser, $this->myPw, $this->myDb);
if (!$this->conn || mysqli_error($this->conn))
{
die ('could not connect');
}
$this->sql = "SELECT img_ym,
img_name,
img_path
FROM gallery
where date_format(img_ym,'%m') = month(now())";//현재 달 사진 출력
$this->result = mysqli_query($this->conn,$this->sql);
if (mysqli_num_rows($this->result) > 0)
{
while($row = mysqli_fetch_assoc($this->result))
{
$this->path = $row['img_path'];
$this->name = $row['img_name'];
$this->aa .="<li><img src='$this->path//$this->name'></li>";
}return $this->aa;
}
else
{
echo "테이블에 데이터가 없습니다.";
}
mysqli_close($this->conn);
}
function last_month() {
$this->conn = mysqli_connect($this->host, $this->myUser, $this->myPw, $this->myDb);
if (!$this->conn || mysqli_error($this->conn))
{
die ('could not connect');
}
$this->sql = "SELECT img_ym,
img_name,
img_path
FROM gallery
where date_format(img_ym,'%m') = month(now()- interval 1 month)";//이전달 사진 출력
$this->result = mysqli_query($this->conn,$this->sql);
if (mysqli_num_rows($this->result) > 0)
{
while($row = mysqli_fetch_assoc($this->result))
{
$this->path = $row['img_path'];
$this->name = $row['img_name'];
$this->aa .="<li><img src='$this->path//$this->name'></li>";
}return $this->aa;
}
else
{
echo "테이블에 데이터가 없습니다.";
}
mysqli_close($this->conn);
}
function next_month() {
$this->conn = mysqli_connect($this->host, $this->myUser, $this->myPw, $this->myDb);
if (!$this->conn || mysqli_error($this->conn))
{
die ('could not connect');
}
$this->sql = "SELECT img_ym,
img_name,
img_path
FROM gallery
where date_format(img_ym,'%m') = month(now()+ interval 1 month)";//다음달 사진 출력
$this->result = mysqli_query($this->conn,$this->sql);
if (mysqli_num_rows($this->result) > 0)
{
while($row = mysqli_fetch_assoc($this->result))
{
$this->path = $row['img_path'];
$this->name = $row['img_name'];
$this->aa .="<li><img src='$this->path//$this->name'></li>";
}return $this->aa;
}
else
{
echo "테이블에 데이터가 없습니다.";
}
mysqli_close($this->conn);
}
}
?>
3. html
이전달 다음달 버튼 만듦.
main.php 요렇게
이어서 ....
'현장실습 🏙' 카테고리의 다른 글
[현장 실습]2021 하계 5주25일~7주34일차 그동안 쫌쫌따리 만든것들 (메인페이지 수정, 팝업창, 글쓰기 페이지) (0) | 2021.10.24 |
---|---|
[현장 실습]2021 하계 5주25일~7주34일차 지옥의 갤러리 이전달 다음달 만들기 (0) | 2021.10.23 |
[현장 실습]2021 하계 5주22~24일차 - 공지사항 내용 테이블에 저장해서 출력하기 (0) | 2021.10.23 |
[현장 실습]2021 하계 5주21일차 - 관리자 페이지 만들기 1 (0) | 2021.10.23 |
[현장 실습]2021 하계 4주20일차 - php와 mysql 을 사용하여 테이블에 사진 저장하고 불러오기 3 (php class 사용) (0) | 2021.10.23 |
댓글
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 정처기 실기 정리
- 리액트
- MySQL
- 갤러리띄우기
- 백준
- 졸업작품준비
- 정처기 실기
- 스마트컨트랙트
- 홈페이지 만들기
- set 객체
- DAPP
- 정보처리기사 실기
- 현장실습 기록
- HTML
- 정보처리기사 실기 정리
- 현장실습
- 이더리움
- php 달력만들기 응용
- 노마드코더
- 블록체인
- CSS
- JavaScript
- css grid
- indexOf()
- 졸업작품
- 정보처리기사
- php게시판만들기
- C언어
- 프로그래머스
- php
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함