웹마스터 팁

http://seokeen.zio.tocheck.php //제로보드 회원과 연동시키는 부분
SelectBox.js //Say Club 셀렉트박스
include.php //북마크 출력
bookmark.php //북마크 입력
bookmark_ok.php //입력;;
bookmark_del.php //북마크 삭제


설치하시려면 bookmark 라는 테이블을 생성해 주셔야 합니다.
이상있는 부분이 발견되거나;;; 하면 댓글 달아주세요;;;

CREATE TABLE bookmark (
  id int(11) NOT NULL auto_increment,
  member_id varchar(20) NOT NULL default '',
  url varchar(255) NOT NULL default '',
  url_name varchar(50) NOT NULL default '',
  PRIMARY KEY  (id)
) TYPE=MyISAM;


check.php ─────────────────────────────────────

<?
ob_start();

$connect = mysql_connect("localhost" ,"아이디", "패스워드") or die(mysql_error());
mysql_select_db("DB네임");

$user_id  = $HTTP_COOKIE_VARS[zetyxboard_userid];
$password = $HTTP_COOKIE_VARS[zetyxboard_password];

$result = @mysql_query("select * from zetyx_member_table where user_id='$user_id' and password='$password'",$connect) or die(mysql_error());
$check = mysql_fetch_array($result);
?>



SelectBox.js ─────────────────────────────────────

function printZSelectBox(selectBox,option) {
        var tmp, name, value, outString, action;
        var id = selectBox["id"];
        var width = selectBox["width"];
        var height = selectBox["height"];
        var bordercolor = selectBox["bordercolor"];
        var bgcolor = selectBox["bgcolor"];
        var fontcolor = selectBox["fontcolor"];
        var focusbgcolor = selectBox["focusbgcolor"];
        var fontsize = selectBox["fontsize"];
        var padding = selectBox["padding"];
        var bullet = selectBox["bullet"];
        var onChange = selectBox["onChange"];
        var select = option["select"];

        if(bordercolor==null) bordercolor = "#888888";
        if(bgcolor==null) bgcolor= "#ffffff";
        if(fontcolor==null) fontcolor="#333333";
        if(focusbgcolor==null) focusbgcolor= "#ededed";
        if(width==null) width=100;
        if(height!=null) height="height="+height; else height = "";
        if(fontsize==null) fontsize="9";
        if(padding==null) padding="1";
        if(bullet==null) bullet="▽";

        outString = "<input type=hidden name='"+id+"'>";
        outString += "<table width="+width+" "+height+" border=0 cellspacing=1 cellpadding=0 bgcolor="+bordercolor+" style='table-layout:fixed;cursor:hand' onClick="showZSelectBox('layer_"+id+"')">n";
        outString += "<tr bgcolor="+bgcolor+">n";
        outString += "<td>n";
        outString += "<table border=0 width=100% height=100% cellspacing=0 cellpadding="+padding+" style='table-layout:fixed;'>n";
        outString += "<col width=></col><col width=15></col>n";
        outString += "<tr>n";
        outString += "<td style='line-height:100%;padding-top:3px;padding-left:3px;' onMouseOver=this.style.backgroundColor='"+focusbgcolor+"' onMouseOut=this.style.backgroundColor='+ ''><div id="+id+"_value style=color:"+fontcolor+";font-size:"+fontsize+"pt;>Select</div></td>n";
        outString += "<td style='font-size:"+fontsize+"pt;padding:0px;color:"+fontcolor+";' align=center>"+bullet+"</td>n";
        outString += "</tr>n";
        outString += "</table>n";
        outString += "</td>n";
        outString += "</tr>n";
        outString += "</table>n";

        outString += "<div id='layer_"+id+"' style='z-index:100; position:absolute; visibility:hidden' onMouseOver=showZSelectBox('layer_"+id+"') onMouseOut=hideZSelectBox('layer_"+id+"')>n";
        outString += "<table border=0 cellspacing=0 cellpadding=0 height=2><tr><td></td></tr></table><table border=0 cellspacing=1 cellpadding=0 bgcolor="+bordercolor+" width="+width+">n";
        outString += "<tr bgcolor="+bgcolor+">n";
        outString += "<td>n";
        outString += "<table border=0 cellspacing=0 cellpadding=0 width=100% style=table-layout:fixed>n";
        outString += "<col style=padding-left:3px;font-size:"+fontsize+"pt;color:"+fontcolor+" width=></col>n";
        for(i=0;i<option.length;i++) {
                tmp = option[i].split(",");
                name = tmp[0];
                value = tmp[1];
                if(value==null) value = "";
                if(onChange!=null&&value) action= "location.href=""+value+""";
                else action = ""selectZSelectBox('"+name+"','"+value+"'+ ','"+id+"')"";
                outString += "<tr onMouseOver=this.style.backgroundColor='"+focusbgcolor+"' onMouseOut=this.style.backgroundColor='' style=cursor:hand><td onClick="+action+" style='padding-top:1px;font-size:"+fontsize+"pt;color:"+fontcolor+"'>"+name+"</td></tr>n";
        }
        
        outString += "</table>n";
        outString += "</td>n";
        outString += "</tr>n";
        outString += "</table>n";
        outString += "</div>n";
        document.writeln(outString);

        if(select!=null) {
                tmp = option[select].split(",");
                name = tmp[0];
                value = tmp[1];
                if(value==null) value = "";
                document.all[id+"_value"].innerHTML = name;
                document.all[id].value = value;
        }
}

function showZSelectBox(id) {
        document.all[id].style.visibility = '';
}

function hideZSelectBox(id) {
        document.all[id].style.visibility = 'hidden';
}

function selectZSelectBox(name,value,id) {
        document.all[id+"_value"].innerHTML = name;
        document.all[id].value=value;
        document.all["layer_"+id].style.visibility = 'hidden';
}



include.php ────────────────────────────────
include.php 을 원하는 부분에 include 하시면 됩니다.;;;;

<script src="SelectBox.js"></script>
<script>
        var selectBox = new Array();
        var option = new Array();

        selectBox["id"] = "BookMark";
        selectBox["fontsize"] = "9";
        selectBox["width"] = "148";
        selectBox["height"] = "19";
        selectBox["fontcolor"] = "#333333";
        selectBox["bordercolor"] = "#666666";
        selectBox["focusbgcolor"] = "#f0f0f0";
        selectBox["bullet"] = "<img src=select_bul.gif width=10 height=6 border=0>";
        selectBox["padding"] = "0";
        selectBox["onChange"] = true;
        option[0] = "북마크";

        <?
        include ("check.php");

        @$temp   = "select * from bookmark where member_id='$check[user_id]'";
        @$result = mysql_query($temp,$connect);
        $total   = mysql_affected_rows();

        for ($i=0; $i<$total; $i++)
        {
                $m = $i+1;
                $data = mysql_fetch_array($result);
                echo "option[$m] = "$data[url_name],$data[url]";rn";
        }
        ?>

        option["select"] = 0;
        printZSelectBox(selectBox,option);
</script>

<?
if($check[level]) $a_link = "<a href='bookmark.php' title='현재 페이지 북마크하기'>";
else $a_link = "<a href='#' onclick='alert(" 로그인된 회원에 한해 이용하실 수 있습니다. ")' title='현재 페이지 북마크하기'>";
echo $a_link;
?>

북마크추가</a>
</form>



bookmark.php ────────────────────────────────

<?
//$HTTP_REFERER 변수를 받아온다.

include ("check.php");
if(!$check[level]||$check[level]==10) error ("사용권한이 없습니다. 로그인해주세요");
$temp = mysql_query("select * from bookmark where member_id='$check[user_id]'");

<form name='bookMark' action='bookmark_ok.php' method='post' enctype='multipart/form-data'>
북마크 이름 : <input type='text' name='url_name' value=''>
URL : <input type='text' name='url' value='<?=$HTTP_REFERER?>'>
<input type=submit value='  SUBMIT  '>
</form>

<table>
<tr align='center'>
<td><b>Name</b></td><td><b>URL</b></td><td><b>Del</b></td>
</tr>
<?
while ($data=mysql_fetch_array($temp))
{
        echo "<tr>
        <td>$data[url_name]</td>
        <td><a href='$data[url]' target='_blank'>$data[url]</td>
        <td><a href='bookmark_del.php?id=$data[id]'>삭제</a></td>
        </tr>";
}
?>
</table>



bookmark_ok.php ────────────────────────────────

<?
include ("check.php");
mysql_query("insert into bookmark (member_id,url,url_name) values ('$check[user_id]','$url','$url_name')");
echo "<meta http-equiv='refresh' content='0;URL=bookmark.php'>";
?>



bookmark_del.php ────────────────────────────────

<?
include ("check.php");
mysql_query("delete from bookmark where id ='$id'");
echo "<meta http-equiv='refresh' content='0;URL=bookmark.php'>";
?>
제목 글쓴이 날짜
PHP+MSSQL?(수정판) [11] 씨파개 2003.05.10
if 시리즈 2탄.. ㅡㅡ;; [9] 씨파개 2003.05.05
if 시리즈 1탄! [15] 씨파개 2003.04.28
[mics'php] 2. PHP 사용 시스템 구축하기 [3] file TheMics 2003.04.17
개판 오분전 세션 - 5 미친개 2003.04.08
NZEO 이메일 인증 따라하기 [또 수정 --;] [44] file teslaMINT 2003.02.22
야구 자료실 만들기 1 [8] file 한꼬마 2003.01.30
파일 하나로 끝내는-_- NZEO 북마크...-_-a [14] ineal 2003.01.13
웹 인증 보호, 윈도우 로그인 폼 이용 (authenticate) [9] file 둘리나라™ 2003.01.13
[추천 강의] NZEO.COM 에서 쓰는 북마크 구현하기 [5] 東氣號太 2002.12.28
[동주아빠] PHP 게시판(15강) - 입력 글 DB 저장(1) [2] 손병목 2002.12.25
[동주아빠] PHP 게시판(15강) - 입력 글 DB 저장(1) [3] 손병목 2002.12.25
[동주아빠] PHP 게시판(14강) - 게시판용 테이블 만들기 [3] 손병목 2002.12.25
모닝샵 이용해서 쇼핑몰 만들기 (설치에서 쇼핑몰 환경 설정) [7] file 한꼬마 2002.11.20
초보의 초보를위한 강의 PHP를 활용한 페이지 암호걸기 #3 [10] 아이쿠 2002.11.15
초보의 초보를위한 강의 PHP를 활용한 페이지 암호걸기 #2 [8] 아이쿠 2002.11.13
초보의 초보를위한 강의 PHP를 활용한 페이지 암호걸기 #1 [9] file 아이쿠 2002.11.13
[추천 소스] nzeo에 있는 북마크 기능 구현하기(hot key 는 제외) 초허접 강좌 [10] 정승재 2002.10.22
[PHP 초보에서 중수로 - 쿠키편] 1강 : 쿠키의 이해 [2] file TheMics 2002.08.31
꼭 알아야 하는 4가지 쿼리문 Mr. JH 2002.08.22