사이트 내 전체검색
PHP,MYSQL 메인테이블에서 없는 자료만 추가하기 (순서정렬)
로빈아빠
https://cmd.kr/server/1063 URL이 복사되었습니다.

본문

1차.   무대뽀 + 많은 원데이타인경우 가능하게..

1. $g4[board_table] 에서 해당그룹의 기본내용을 가져온뒤
2. 동호회메뉴중 삭제된 원게시판그룹을 삭제하고
3. 추가된 게시판을 저장함..


$arow=array();
$sql="select * from $g4[arc_board_table] where cl_id='$g4[cl_id]' order by bo_ord";
$result = sql_query($sql);
$aboard=array();
$last=0;
$filter="";
for ($last=0; $row=sql_fetch_array($result); $last++) {
 $board=sql_row($g4[board_table],"where bo_table='$row[bo_table]'");
 if (!$board) {
  sql_query("delete from $g4[arc_board_table] where bo_table='$row[bo_table]'");
  continue;
 }
 $last++;
 $row[bo_ord]=$last;
 $arow[$last]=$row;
 $aboard[]=$row[bo_table];
 if ($filter) $filter.=",";
 $filter.="'$row[bo_table]'";
}

$sql = " select * from $g4[board_table] where gr_id='arc' and bo_table not in ($filter) order by bo_table ";
$result = sql_query($sql);
//echo $sql;

for ($i=0; $row=sql_fetch_array($result); $i++) {
 if (in_array($row[bo_table],$aboard)) {
  //echo "$row[bo_table]<BR>";
  continue;
 }
 $last++;
 $row[bo_ord]=$last;
 $row[bo_subject2]=$row[bo_subject];
 $arow[$last]=$row;
}
---------------------------------------------------
2차 원테이블 한번에 읽어 처리하기
$aboard=array();

$sql = " select * from $g4[board_table] where gr_id='arc' order by bo_table ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
 $aboard["{$row[bo_table]}"]=$row;
}

$arow=array();
$sql="select * from $g4[arc_board_table] where cl_id='$g4[cl_id]' order by bo_ord";
$result = sql_query($sql);
$last=0;
$filter="";
//var_dump($aboard);
$abo_table=array();
for ($last=0; $row=sql_fetch_array($result); $last++) {
 if (!$aboard["$row[bo_table]"]) {
  sql_query("delete from $g4[arc_board_table] where bo_table='$row[bo_table]'");
  continue;
 }
 $last++;
 $row[bo_ord]=$last;
 $arow[$last]=$row;
 $abo_table[]=$row[bo_table];
 if ($filter) $filter.=",";
 $filter.="'$row[bo_table]'";
}


foreach ($aboard as $bd=>$row) {
 if (in_array($row[bo_table],$abo_table)) {
  //echo "$row[bo_table]<BR>";
  continue;
 }
 $last++;
 $row[bo_ord]=$last;
 $row[bo_subject2]=$row[bo_subject];
 $arow[$last]=$row;
}

댓글목록

등록된 댓글이 없습니다.

1,139 (14/23P)

Search

Copyright © Cmd 명령어 3.144.15.7