웹마스터 팁





미리보기 



 

 

한글 다 깨지니 


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

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


제목 글쓴이 날짜
메인 로고 및 메인 이미지 변경 방법 [1] file okcashbag042 2015.04.08
(version 1.6)새글과 새댓글을 알림받는 앱을 직접 만들어보세요(XE 홈페이지와 연동되는 GCM을 이용한 푸시 안드로이드 앱 만들기 가이드-XE 알림센터 연동) [23] 단희아빠 2015.03.21
누리고 Ncart V1.6.1 주문페이지에서 총구매금액에 배송비가 선결제, 착불과 상관없이 무조건 포함되어 표시되는 문제 수정방법 [2] XE템플릿 2015.03.12
압축 풀어 설치했던 XE를 git으로 변환하기 [6] 기진곰 2015.02.25
스케치북 최신버전에서 미리 덧글 입력해두기 [5] file LI-NA 2015.02.18
300기가 Zboard4->XE 이전기 [14] file forest535 2015.02.13
DB LOCK으로 인한 사이트 마비와 사례, 조치 [2] onTrust 2015.01.24
[시니시즘] 비회원에게 파일 다운로드 권한이 없다고 뜰 때 시니시즘 2015.01.15
추천 웹 디자인, 모바일 디자인, CSS3, UI/UX 애니메이션을 확인할 수 있는 블로그 file 나도모름 2015.01.14
Hostinger(호스팅어) 등 해외 서버에서 XE 설치화면이 깨진다면 [9] file YJSoft 2015.01.11
timezone (타임존) 관련한 문제 (SERVER, DBMS, PHP, XE) [2] 세상의모든계산기 2015.01.07
구글 접속이 어려운 지역에서 홈페이지 속도 저하 관련 [2] 상해파 2014.12.31
관리자 페이지 날짜 검색과 스크랩. [1] 무얼까2 2014.12.24
위젯 많은 페이지 - 부하 분산으로 속도 향상하기 [4] 엘카 2014.12.12
파일 삭제시 (글 수정시 파일삭제 / 파일관리에서 삭제 등) 사용자정의값이 삭제되지 않도록 패치 [3] sejin7940 2014.12.11
폰갭 작업시 폰 내부 html에 변수 전달 방법 (get) Happyphp 2014.12.09
PDF 뷰어 팁 [4] 돼지코구뇽 2014.12.06
페이지에 명언,좋은글,책속의 한줄 랜덤으로 뿌리기 [1] file 고니 2014.12.02
부트스트랩 툴팁 , 팝오버 TIP file 돼지코구뇽 2014.11.17
html 붙여넣기 가능한 무료 익명 채팅 프로그램(초간단) [1] file 임채원임 2014.11.17