웹마스터 팁





미리보기 



 

 

한글 다 깨지니 


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

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


제목 글쓴이 날짜
문서페이지가 수정이 되지 않는 문제 [2] file monet 2015.07.07
홈페이지 속도가 느린 이유.(팁같지도 않은 팁) [11] 가브리엘조 2015.06.27
포인트 복권 모듈 관리자 페이지 1.7이상에 맞게 [10] file 착한악마 2015.06.10
타임라인 모듈 두개 이상 생성 및 페이지가 넘어가지 않은 문제에 관하여 함삐까 2015.06.01
(version 1.6)새글과 새댓글을 알림받는 앱을 직접 만들어보세요(XE 홈페이지와 연동되는 GCM을 이용한 푸시 안드로이드 앱 만들기 가이드-XE 알림센터 연동) [23] 단희아빠 2015.03.21
XE 외부페이지 직접접속 차단 및 다국어 설정팁 [4] 라르크앙시엘 2012.01.01
누리고 Ncart V1.6.1 주문페이지에서 총구매금액에 배송비가 선결제, 착불과 상관없이 무조건 포함되어 표시되는 문제 수정방법 [2] XE템플릿 2015.03.12
XE 비회원이 귀찮게 이메일 홈페이지 입력 안하도록 하기 [7] jhrun 2012.12.16
페이지에 명언,좋은글,책속의 한줄 랜덤으로 뿌리기 [1] file 고니 2014.12.02
구글 접속이 어려운 지역에서 홈페이지 속도 저하 관련 [2] 상해파 2014.12.31
관리자 페이지 날짜 검색과 스크랩. [1] 무얼까2 2014.12.24
위젯 많은 페이지 - 부하 분산으로 속도 향상하기 [4] 엘카 2014.12.12
xe 에디터를 외부페이지에사용하기 [26] 정박사닷컴 2012.07.11
홈페이지 접속시 XE를 바로 실행하기 [7] ezi 2011.08.20
홈페이지 제작 시, 개인정보관련/회원가입약관 처리에 대해서 [1] 양파F 2014.08.23
관리자페이지의 '서버정보출력'에 '절대경로' 가 출력되게 하는 방법 [3] sejin7940 2014.08.26
외부 페이지 작업시 페이징 작업 함수 Happyphp 2014.08.12
외부 페이지에서 회원 extra_vars 변수 가져오기 [1] Happyphp 2014.07.09
관리자페이지에서 콘텐츠->파일 에서 등록된 파일 전체 리스트에 이미지가 바로 나타나도록 [2] sejin7940 2014.06.19
홈페이지에 접속한 장치의 너비 구하기 [3] CosignStudio 2014.05.28