웹마스터 팁





미리보기 



 

 

한글 다 깨지니 


페이지 상단에 밑에 태그 넣고

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


파일 저장은 UTF-8 로 반드시 해야 합니다.(메모장 또는 editplus 추천 다른 에디터는 제대로 적용안되더군요)



1.파일형식으로  코딩


밑의 코드페이지와 위의 첨부파일을 같은 폴더에 둡니다.



<?


$mentFile = "book.txt";  

$fp = fopen($mentFile, "r");


while(!feof($fp)) $ment[] = fgets($fp, 1024);

 





//### $ment 배열에서 랜덤키 생성

$key = array_rand($ment);

### 랜덤 생성된 명언 출력

echo $text_this=$ment[$key];


?>



2.my_sql 연동방식


 

1.테이블 생성


CREATE TABLE IF NOT EXISTS `books` (

  `no` int(11) NOT NULL AUTO_INCREMENT,

  `content` text NOT NULL,

  PRIMARY KEY (`no`),

  KEY `no` (`no`)

)


 


2.mysql 에 위에 첨부된 book.txt 집어 넣습니다.

 

phpmyadmin 에서 import 탭에서 


CSV using LOAD DATA  book.txt 파일 첨부

CSV using LOAD DATA 체크

필드 구분자 ->   \t

필드 구분자-> content


로 하는것 유의 


방법은 서기님 강좌 참고http://vod.singsinghe.co.kr/movie/php/48/php_48.html


 




3.코딩


 

<?

$conn=mysql_connect("","","");

mysql_select_db("");


<embed autostart="false" invokeurls="false" width="100%" height="100%" wmode="transparent" id="syeatistorycom49563" src="http://s1.daumcdn.net/cfs.tistory/v/0/blog/plugins/CallBack/callback.swf?destDocId=callbacknestsyeatistorycom49563&id=49&callbackId=syeatistorycom49563&host=http://syea.tistory.com&float=left&" allowscriptaccess="never" menu="false" type="application/x-shockwave-flash" allownetworking="internal" enablehtmlaccess="false" allowhtmlpopupwindow="false" />



$random = rand(1,283);  //no 의 처음과 끝사이에 랜덤하게 1개 $random 변수에 지정 (db 넘버 반드시 확인 )


$query="select * from books where no='$random'"; // 랜덤 생성된 1개 no 필드에서 가져오기


$result=mysql_query($query,$conn);

$data=mysql_fetch_array($result);

$text_this=$data[1]; 



echo $text_this;




?>

 


하면 됩니다..


3.

JQuery 로 

 뿌리기 

 

 

위와 같이 바로 해도 되고..같은 폴더에 코딩 한거 두고 뿌리기 원하는 페이지에 

JQuery 로 가져 와도 됩니다.

 

 

 

 

 

<head>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script>

$(document).ready(function() {

 

    $("#div1").load("books.php");

 

});

 

 

</script>

</head>

<body>

 

<div id="div1"></div><div id="div"></div>

 

</body>

 

4.이쁘게 둥근 테두리로 만들기

 

 

 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<style>

td{

font-size:12px;


}

</style>


<table cellpadding=0 cellspacing=0 border=0 width=300 >

<tr height=1>

<td rowspan=4 width=1></td>

<td rowspan=3 width=1></td>

<td rowspan=2 width=1></td>

<td width=2></td>

<td bgcolor=#3DB7CC></td>

<td width=2></td>

<td rowspan=2 width=1></td>

<td rowspan=3 width=1></td>

<td rowspan=4 width=1></td>

</tr>

<tr height=1>

<td bgcolor=#3DB7CC></td>

<td bgcolor=#D4F4FA></td>

<td bgcolor=#3DB7CC></td>

</tr>

<tr height=1>

<td bgcolor=#3DB7CC></td>

<td colspan=3 bgcolor=#D4F4FA></td>

<td bgcolor=#3DB7CC></td>

</tr>

<tr height=2>

<td bgcolor=#3DB7CC></td>

<td colspan=5 bgcolor=#D4F4FA></td>

<td bgcolor=#3DB7CC></td>

</tr>

</table>


<table cellpadding=0 cellspacing=0 border=0 width=300 >

<tr >

<td width=1 bgcolor=#3DB7CC></td>

<td valign=top bgcolor=#D4F4FA>

<table cellpadding=0 cellspacing=0 border=0 width=100%>

<tr height=0><td></td>

<td></td>

<td></td>

</tr>

<tr>

<td width=0></td>

<td align="center">


<?

$conn=mysql_connect("localhost","","");

mysql_select_db("");




$random = rand(1,283);


$query="select * from books where no='$random'";


$result=mysql_query($query,$conn);

$data=mysql_fetch_array($result);

$text_this=nl2br($data[1]);



echo $text_this;




?>



</td>

<td width=0></td>

</tr>

<tr height=0>

<td></td>

<td bgcolor=#D4F4FA></td>

<td></td>

</tr>

</table>

</td>

<td width=1 bgcolor=#3DB7CC></td>

</tr>

</table>

<table cellpadding=0 cellspacing=0 border=0 width=300 >

<tr height=2>

<td rowspan=4 width=1></td>

<td width=1 bgcolor=#3DB7CC></td>

<td width=1 bgcolor=#D4F4FA></td>

<td width=2 bgcolor=#D4F4FA></td>

<td bgcolor=#D4F4FA></td>

<td width=2 bgcolor=#D4F4FA></td>

<td width=1 bgcolor=#D4F4FA></td>

<td width=1 bgcolor=#3DB7CC></td>

<td rowspan=4 width=1></td>

</tr>

<tr height=1>

<td rowspan=3></td>

<td bgcolor=#3DB7CC></td>

<td colspan=3 bgcolor=#D4F4FA></td>

<td bgcolor=#3DB7CC></td>

<td rowspan=3></td>

</tr>

<tr height=1>

<td rowspan=2></td>

<td bgcolor=#3DB7CC></td>

<td bgcolor=#D4F4FA></td>

<td bgcolor=#3DB7CC></td>

<td rowspan=2></td>

</tr>

<tr height=1>

<td></td>

<td bgcolor=#3DB7CC></td>

<td></td>

</tr>

</table>


제목 글쓴이 날짜
XE 비회원이 귀찮게 이메일 홈페이지 입력 안하도록 하기 [7] jhrun 2012.12.16
제로보드4에서 xe로 이전시 갤러리 게시판 이미지 깨어지는 현상 해결방법 [2] 최르토스 2012.04.22
스케치북5 1.7.0 버전 모바일 게시판 스킨 댓글수 안나올때 [2] 키스투엑스이 2014.10.22
제가 쓰는 자동링크 (스킨수정) [4] okiz 2014.04.29
사용자 매뉴에 회원정보와 포인트설정 바로가기 기능 삽입 [1] file 간장게장같은남자 2015.01.23
사용자정의 중 전화번호 형식을 쓰는경우 - 사이에 한칸씩 여백이 생기는 걸 없애는방법 [1] sejin7940 2015.01.23
xe 폰갭 제작시 admob 광고 글쓰기 방해 하지 않으려면 한꼬마 2015.01.26
부트스트랩 관련 버튼안에 체크박스 돼지코구뇽 2015.01.25
DB LOCK으로 인한 사이트 마비와 사례, 조치 [2] onTrust 2015.01.24
제로보드 DTREE 메뉴 적용하기 ( 카테고리 선택기 흉내 냈습니다.) [5] file 조성우371 2009.01.17
게시판에서 태그 기준으로 검색하면 임시저장글들도 노출되는 버그 수정 sejin7940 2015.01.23
문서권한 지정 애드온 1.7에서 동작하게 [2] socialskyo 2015.01.17
kin 모듈 게시물 -> board로 게시물 옮기기 편법 file 꾸링 2015.01.20
한글지원하는 글자수 자르기 함수 [3] pezex 2014.08.11
사이트 종합해서 접속자 아이피 검색 file StyleRoot 2015.01.19
웹서버 php에서 한글언어 깨지거나 오류날때 방법@ 뭘봐첨봐 2015.01.19
포인트 부족 시 글 열람 금지 설정해도, 글을 볼 수 있는 버그 수정 [1] sejin7940 2015.01.18
파일첨부 컨트롤러에 관하여 (첨부파일이 문자열이나, 인코딩되어있는 이미지 등) [1] 410contents 2015.01.16
스팸 단어가 뭔지 스패머들에게 알려주지마세요. 썰레발리오 2015.01.16
[시니시즘] 비회원에게 파일 다운로드 권한이 없다고 뜰 때 시니시즘 2015.01.15