MySQL 디비저장후 연속으로 저장된 값 활용할때
페이지 정보
본문
데이타베이스에 저장한후 바로 그것의 값을 추출해서 다른 것에 활용하고자 할때
테이블이름 : tbl_table
필드정의 : no, idx , wdate, field_1, field_2
<?php
$TABLE_NAME = 'tbl_table';
테이블이름 : tbl_table
필드정의 : no, idx , wdate, field_1, field_2
<?php
$TABLE_NAME = 'tbl_table';
$query = "select min(idx) as idx from ". $TABLE_NAME ." where idx like '$current_pointer%'";
$result = mysql_query($query) or die(mysql_error());
$data = mysql_fetch_row($result) or die(mysql_error());
$data = $data[0];
if ($data) $append_idx = $data - 1;
else $append_idx = '999999999';
if ($append_idx < 1) Error(26);
elseif ($append_idx < 10) $append_idx = "00000000" . $append_idx;
elseif ($append_idx < 100) $append_idx = "0000000" . $append_idx;
elseif ($append_idx < 1000) $append_idx = "000000" . $append_idx;
elseif ($append_idx < 10000) $append_idx = "00000" . $append_idx;
elseif ($append_idx < 100000) $append_idx = "0000" . $append_idx;
elseif ($append_idx < 1000000) $append_idx = "000" . $append_idx;
elseif ($append_idx < 10000000) $append_idx = "00" . $append_idx;
elseif ($append_idx < 100000000) $append_idx = "0" . $append_idx;
$query = "insert into ". $TABLE_NAME ." ( ";
$query .= " idx, wdate, field_1, field_2 ";
$query .= ") values (";
$query .= " '". $append_idx ."' ";
$query .= ", now() ";
$query .= ", '". $_POST["field_1"] ."' ";
$query .= ", '". $_POST["field_2"] ."' ";
$query .= ")";
mysql_query($query) or die(mysql_error());
$query = "select field_1, field_2 from ". $TABLE_NAME ." where idx = '". $append_idx ."' ";
$result = mysql_query($query) or die(mysql_error());
$data_ = mysql_fetch_array($result);
$view_1 = $data_["field_1"];
$view_2 = $data_["field_2"];
?>
?>
댓글목록
등록된 댓글이 없습니다.