작성일 댓글 남기기

[스크립트] 새로고침없는 DB검색 리스트 뿌리기 JS+PHP

글쓴이 : 개발소발 날짜 : 06-01-14 14:14 조회 : 1701

http://www.ebaygolf.co.kr/shop_dmz/shop_search.php (285)

거침마루님의 Dynamic.js를 응용해서 해 봤는데 재미 있군요.
스크립트로 테이블을 만들어 innerHTML로 뿌리는 식입니다.

다음에는 ajax로 해 봐야 겠습니다.

현재 운영하는 싸이트의 소스 그대로 올리니 이해 해 주세요.
————검색 하는 페이지———————–




————————여기까지가 검색하는 페이지———————

여기부터는 DB검색해서 스크립트로 테이블을 만드는 페이지 입니다.
…………………………….DB검색 쿼리문
…………………………….
…………………………….
if($z < 1){
echo”alert(‘선택하신 지역에 골프관련 매장 데이터가 없습니다.’);
“;
exit;
}

echo “var objTable, objTBody, objRow, objCell
“;

echo “objTable = document.all.s_go;
“;
echo “t_lg = objTable.rows.length;
“;

echo ” for(p=0; p “;
echo ” objTable.deleteRow();
“;
echo ” }
“;

echo “objTBody = document.createElement(‘TBODY’);
“;
echo “objTable.appendChild(objTBody);
“;

echo “objRow = document.createElement(‘TR’);
“;
echo “objRow.setAttribute(‘bgcolor’,’#EBEBEB’,0);
“;
echo “objTBody.appendChild(objRow);
“;
echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘height’,1,0);
“;
echo “objCell.setAttribute(‘colspan’,7,0);
“;
echo “objRow.appendChild(objCell);
“;
//echo “objCell.innerHTML = ‘‘;
“;

echo “objRow = document.createElement(‘TR’);
“;
echo “objRow.setAttribute(‘bgcolor’,’#FFFFFF’,0);
“;
echo “objTBody.appendChild(objRow);
“;
echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘height’,2,0);
“;
echo “objCell.setAttribute(‘colspan’,7,0);
“;
echo “objRow.appendChild(objCell);
“;
//echo “objCell.innerHTML = ‘‘;
“;

echo “objRow = document.createElement(‘TR’);
“;
echo “objRow.setAttribute(‘bgcolor’,’#F9F9F9′,0);
“;
echo “objRow.setAttribute(‘align’,’center’,0);
“;
echo “objTBody.appendChild(objRow);
“;
echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘width’,’5%’);
“;
echo “objCell.setAttribute(‘height’,30);
“;
echo “objCell.setAttribute(‘align’,’center’);
“;
echo “objCell.setAttribute(‘className’,’Green_txt01′);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘width’,’27%’);
“;
echo “objCell.setAttribute(‘className’,’Green_txt01′);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘width’,’48%’);
“;
echo “objCell.setAttribute(‘className’,’Green_txt01′);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘className’,’Green_txt01′);
“;
echo “objCell.setAttribute(‘width’,’20%’);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘‘;
“;

for($i=0; $i < $z; $i++)
{
$k = $i+1;
echo “objRow = document.createElement(‘TR’);
“;
echo “objRow.setAttribute(‘bgcolor’,’#ffffff’,0);
“;
echo “objTBody.appendChild(objRow);
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘colspan’,2,0);
“;
echo “objCell.setAttribute(‘height’,25,0);
“;
echo “objCell.setAttribute(‘align’,’center’);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘”.$k.”‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘colspan’,2,0);
“;
echo “objCell.style.padding = ‘0,10,0,10’;
“;
echo “objCell.setAttribute(‘className’,’Green_txt01′);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘”.htmlspecialchars($g_shop[‘s_name’][$i]).”‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘colspan’,2,0);
“;
echo “objCell.style.padding = ‘0,10,0,10’;
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘”.htmlspecialchars($g_shop[‘s_addr’][$i]).”‘;
“;

echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.style.padding = ‘0,10,0,10’;
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘”.$g_shop[‘s_tell’][$i].”‘;
“;

if($k != $z){
echo “objRow = document.createElement(‘TR’);
“;
echo “objTBody.appendChild(objRow);
“;
echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘background’,’/shop_dmz/image/MyMGA/LineDot666px.gif’);
“;
echo “objCell.setAttribute(‘colspan’,7,0);
“;
echo “objRow.appendChild(objCell);
“;
//echo “objCell.innerHTML = ‘‘;
“;
}
}

echo “objRow = document.createElement(‘TR’);
“;
echo “objTBody.appendChild(objRow);
“;
echo “objCell = document.createElement(‘TD’);
“;
echo “objCell.setAttribute(‘colspan’,7,0);
“;
echo “objRow.appendChild(objCell);
“;
echo “objCell.innerHTML = ‘‘;
“;
?>

————————DB검색해서 스크립트로 테이블 만드는 페이지 끝——————–

실제로 응용해서 사용하고 있는 싸이트 주소 입니다.
http://www.ebaygolf.co.kr/shop_dmz/shop_search.php

그냥 이런식으로도 사용하는 넘이 있구나….생각 해 주세요 ^^;

답글 남기기

이메일 주소는 공개되지 않습니다.