웹마스터 팁





미리보기 



 

 

한글 다 깨지니 


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

<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] Happyphp 2014.07.26
CURL 등 리퀘스트가 느리다고 생각될때 [1] 銀童 2014.07.25
xe module, sample 생성기 [9] 천재ㅐ재 2014.07.24
아이디 첫글자에 숫자 허용 [2] wooildang 2014.07.24
[초보팁] .htaccess 파일을 이용하여 여러가지 주소 한 주소로 리다이렉트 하기 ( 주소 통합 ) [5] 태풍_님 2014.07.23
빈공간 더블 클릭시 상하 이동 스크립트 socialskyo 2014.07.23
php로 간단하게 신규쪽지(읽지않은쪽지) 표시해주기 [2] 졸라맨 2014.07.23
간단하게 외부 SMTP 로 인증메일 보내기. [1] file AJKJ 2014.07.22
Windows10 에서 IIS + mysql + PHP 설치 [10] file HSJI 2014.07.21
회원 비밀번호 수정시 자동으로 로그아웃 되게 하는 방법 [4] sejin7940 2014.07.18
게시판 글 엑셀로 출력하기(확장변수 포함) [15] 한이73 2014.07.17
모바일(또는 textarea형)에서 댓글 수정시 줄바꿈 유지되도록 수정 [2] sejin7940 2014.07.17
댓글등록에 단축키 사용하기 ひりゅう. 2014.07.15
SocialXE 관련 사용팁 적용 수정 파일 [3] file 휘즈 2014.07.13
lang.xml 파일 다이어트 자동화 [5] file 산하2 2014.07.09
편리한 안드로이드 크로스 브라우징 테스트 Tip - 안드로이드 가상화 file AJKJ 2014.07.09
외부 페이지에서 회원 extra_vars 변수 가져오기 [1] Happyphp 2014.07.09
XE 알림센터 Lite 사용시에 쪽지나 호출에 대해서만 알림음을 적용하기 [17] SeungXE 2014.07.06
MRTG에서 네트워크및 CPU, 메모리점유율을 기록하기 ひりゅう. 2014.07.05
xe 1.7.4 이상 object cache 및 template cache 적용 방법 [3] XE러버 2014.07.04