웹마스터 팁





미리보기 



 

 

한글 다 깨지니 


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

<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>


제목 글쓴이 날짜
파일첨부 된 글을 게시글 이동시, 사용자정의 값이 전부 삭제되는 버그 패치 [5] sejin7940 2014.11.20
누리고 쇼핑몰 - 모바일 버전에서 상품몰에 취소/환불 부분이 적용안되는부분 해결 하는 팁 garnecia 2014.11.23
누리고쇼핑몰-모바일 이니시스 결제에서 필수요청값 누락 에러로 결제 안되는것 해결하는 미봉책 garnecia 2014.11.23
XE 코어의 메일전송을 우리알림 모듈로 대체하는 방법 [30] file GG 2014.11.24
xe 어플 개발시 키캡 4.4.4 미만 업로드 문제 [3] Happyphp 2014.11.25
Animate 사용 돼지코구뇽 2014.11.26
bing 번역 함수 만들어 사용하기 Happyphp 2014.11.26
jq로 데이터 입력시 enter키 먹게 하기 [3] Happyphp 2014.11.27
페이지에 명언,좋은글,책속의 한줄 랜덤으로 뿌리기 [1] file 고니 2014.12.02
PDF 뷰어 팁 [4] 돼지코구뇽 2014.12.06
IE에서 스크립트 생성 iframe 요소에 name 속성 지정이 무시될 때 신평 2014.12.08
폰갭 작업시 폰 내부 html에 변수 전달 방법 (get) Happyphp 2014.12.09
파일 삭제시 (글 수정시 파일삭제 / 파일관리에서 삭제 등) 사용자정의값이 삭제되지 않도록 패치 [3] sejin7940 2014.12.11
위젯 많은 페이지 - 부하 분산으로 속도 향상하기 [4] 엘카 2014.12.12
여러게시물을 작성시 쓰기버튼 노출의 여부로 고생할 때.. file BJ람보 2014.12.15
제이쿼리 충돌시 팁 바나나소프트 2014.12.15
날짜비교 함수 [1] 별을따는소년 2014.12.17
CSS 코드를 손쉽게 prefix/minify 변환해주는 사이트 file sojumeister 2014.12.18
XE 템플릿에서 $_SESSION 변수 사용하기 신평 2014.12.21
관리자 페이지 날짜 검색과 스크랩. [1] 무얼까2 2014.12.24