다음페이지 이동시 값 넘기기 질문요... 채택완료
DB값을 불러와서 페이지 넘길때 같이 2개의 값을보내려고 하는데요.
한개는 보내지는 나머지 한개가 계속 빈칸으로 넘어가서요... 코드를 어떻게 해야 넘어가는지좀 알려주세요
아래는 제가 작성한 소스인데 확인 부탁드려요.
1번 방법
$sql = "select * from ".$g5['product_phone_table']." where (1) ";
$sql .= " order by ph_order desc limit 0, 6"; $que = sql_query($sql); while ($row = sql_fetch_array($que)) { $list_it_id = $row['it_id']; $list_t_idx = $row['t_idx']; $sql = "select * from ".$g5['telecom_table']." where (1) "; $que = sql_fetch($sql); $list_t_name = $row['t_name'];
$list_ph_size = $row['ph_size']; $list_ph_name = $row['ph_name'];
if ($ca_id1 == "$ca_id1") { $list_href = "location.href='".G5_URL."/main/service/product_view.php?it_id=".$list_it_id."&t_idx=".$list_t_idx; $list_href .= "&t_name=".$list_t_name."'"; }
결과 http://localhost/main/service/product_view.php?it_id=1583393222&t_idx=3&t_name=">localhost/main/service/product_view.php?it_id=1583393222&t_idx=3&t_name=
이렇게 idx 값은 넘어가는데 name 값이 안넘어갑니다.
2번 방법
$sql2 = "select * from ".$g5['telecom_table']." where (1) "; $que2 = sql_fetch($sql2);
sql 과 que 이름을 다르게 해봤습니다. 결과는 동일해요
3번 방법
$sql2 = "select * from ".$g5['telecom_table']." where (1) and t_name = '".$row['t_idx']."'"; $row2 = sql_fetch($sql2); $list_t_name = $row2['t_name'];
이렇게 변경해봤습니다. 결과는 역시 동일합니다...
계속 시도를 하고 있는데 도저히 해결이 안되요...
원래 값을 넘길때는 하나의 테이블에서만 넘길수 있는건가요?
두개의 테이블에서 각각 값을 못넘기나요?
두개의 테이블에서 값을 받아서 보내려고 하는 이유가 product_phone_table 테이블에는 해당하는 값이 있는데 네임값이 없고 telecom_table에는 네임값이 있어서 입니다.
DB에 값을 생성해도 되지만 그렇게 되면 또 일이 복잡해져서요...
이상태에서 보낼수 있는 방법이 없나요?
답변 2개
조인(left join)해서 하면 좋을텐데 where절 보니까 답이 안보이네요. 이렇게 한 번 해보세요.
</strong></p>
<p>$sql = "select * from ".$g5['product_phone_table']." where (1) ";
$sql .= " order by ph_order desc limit 0, 6";
$que = sql_query($sql);
while ($row = sql_fetch_array($que)) {
$list_it_id = $row['it_id'];
$list_t_idx = $row['t_idx'];
$id1 = $row['id']; //추가
</p>
<p> $sql2 = "select * from ".$g5['telecom_table']." where (1) ";
$que2 = sql_query($sql2);
$row2 = = sql_fetch_array($que2);
$list_t_name = $row2['t_name'];
$id2 = $row2['id']; //추가</p>
<p> $list_ph_size = $row['ph_size'];
$list_ph_name = $row['ph_name'];</p>
<p>
if ($id1 == $id2) {
//if ($ca_id1 == "$ca_id1") { 이 부분이 이상해서 위에 $id1, $id2 추가했어요.
$list_href = "location.href='".G5_URL."/main/service/product_view.php?it_id=".$list_it_id."&t_idx=".$list_t_idx;
$list_href .= "&t_name=".$list_t_name."'";
}
}</p>
<p> </p>
<p><strong>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
왜 되는지는 모르겠네요 ㅠㅠ 제가 작성한것과 비교를 해보면서 공부하겠습니다.
정말 감사합니다~