장

php if? else? 질문인거같아요!

· 2012-03-02 (금) 23:19:32 · 908 · 3
  <?
     include_once("./connect_db.php");
 $code = $_POST["code"];
 
if($member[mb_id]){
    $query=mysql_query("update '$dataname' set occupant='$member[mb_id]',regdate='$date' where code='$code' limit 1",$connect);
}else{
    alert('로그인 해주세요');
}
?>
포스트로 받아온 $code 가 db안에 있는 code 와 일치하는것이 없다면 없는 코드라고 띄우고싶은데 어떻게 해야할까요?
|

댓글 3개

먼저 select 해보시면 될듯 합니다.
<?
if($memeber[mb_id]) {
$query = mysql_query("select count(*) from $dataname where code=$code");
$result = mysql_fetch_row($result);
if($result[0] >0 ) {
$query=mysql_query("update '$dataname' set occupant='$member[mb_id]',regdate='$date' where code='$code' limit 1",$connect);
} else {
echo "코드가 없습니다. 다시 시도하여 주십시오."
}
}else{
alert('로그인 해주세요');
}
?>
밴닛님이 설명 해주셨네요 ㅎㅎ db안에 있는 code를 먼저 뽑아야 겠죵 ㅎㅎ
2012-03-09 (금) 20:24:50
감사
댓글을 작성하시려면 로그인이 필요합니다.

팁게시판

6,077건

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
12-08-29 조회 1,657
12-08-07 조회 1,276
12-08-03 조회 1,310
12-07-31 조회 1,655
12-07-30 조회 1,350
12-07-16 조회 1,488
12-07-15 조회 1,223
12-07-07 조회 1,257
12-07-06 조회 1,345
12-07-03 조회 1,364
12-06-29 조회 1,242
12-06-22 조회 1,365
12-06-17 조회 1,388
12-05-21 조회 1,909
12-05-02 조회 1,332
12-05-02 조회 2,151
12-05-02 조회 1,283
12-04-30 조회 1,354
12-04-30 조회 1,289
12-03-17 조회 1,995
12-03-10 조회 1,387
12-03-08 조회 1,696
12-03-03 조회 1,489
12-02-27 조회 2,795
12-02-17 조회 2,254