2011-08-26 4 views
0

문제가 있습니다. 내 앱이 저장된 데이터를 기반으로 라디오 버튼을 확인하지 않는 것 같습니다. 실제로 두 개의 라디오 버튼이 있습니다. 값의 저장은 작동하지만 사용자가 계정을 사용하여 앱을 다시 방문하면 아무 라디오 버튼도 선택되지 않습니다.db 테이블의 데이터를 기반으로 라디오 버튼을 선택하거나 선택하는 방법은 무엇입니까?

여기에 값의 저장이 작동하지만 1 또는 2 값이 있습니다. 하여 DB 테이블 여기

//User.php 
public function getGalleryMenuStyle($id = ''){ 
    $gallerymenustyle = "SELECT gallery_menu_style FROM users WHERE user_id = ".$id; 
    $this->dbSelectQuery = $gallerymenustyle; 
    $checkedgallerymenustyle = $this->userDBSelect(); 
     if($checkedgallerymenustyle){ 
      return $checkedgallerymenustyle; 
     } else { 
      return false; 
     } 
} 

에서 라디오 버튼의 데이터를 당겨의 코드는 어떻게이 문제를 해결하는 프런트 엔드

$userCats = new User(); 
$user_id = $_SESSION['userData']['user_id']; 
$checkedgallerymenustyle = $userCats->getGalleryMenuStyle($user_id); 

    <div align="center" class="radio_group"> 
     <input type="radio" id="gallerymenustyle1" class="element radio" name="gallerymenustyle[]" value="1" <?php if($checkedgallerymenustyle == 1){ echo "selected"; }?> /> Gallery Link - In the navigation of my website, display one "gallery" link<br /> 
     <input type="radio" id="gallerymenustyle2" class="element radio" name="gallerymenustyle[]" value="2" <?php if($checkedgallerymenustyle == 2){ echo "selected"; }?> /> Category Links - In the navigation of my website, display a separate link to each category. 
    </div> 

의 코드인가? 내 코드에 문제가 있습니까?

+2

당신의 프런트 엔드에 $의 checkedgallerymenustyle''에서 반향 시도해 봤어 적절한 가치를 얻고 있는지보십시오. –

+0

그것은 배열이었습니다 : ( – sasori

+0

ok, 대신에 echo를 사용하는 대신'print_r ($ checkedgallerymenustyle);'시도해보십시오. 배열에있는 것을 보여줄 것입니다, 그리고 여러분이 필요로하는 가치가 있는지를 알 수 있습니다 .. –

답변

2

라디오 버튼은 수행 "선택"

+0

나는이 질문을 게시하기 전에 이미 시도했습니다. – sasori

+0

처음에 "if (...)"를 제거해보십시오. 체크 표시가 나타나면 값이 예상 범위 [1,2]가 아니지만 체크하지 않으면 체크 인 스크립트가 좋지 않습니다. – Louis

0

하지 "확인"을 사용하여이

<div align="center" class="radio_group"> 
     <input type="radio" id="gallerymenustyle1" class="element radio" name="gallerymenustyle[]" value="1" <?php if($checkedgallerymenustyle == 1){ echo "checked=\"yes\""; }?> /> Gallery Link - In the navigation of my website, display one "gallery" link<br /> 
     <input type="radio" id="gallerymenustyle2" class="element radio" name="gallerymenustyle[]" value="2" <?php if($checkedgallerymenustyle == 2){ echo "checked=\"yes\""; }?> /> Category Links - In the navigation of my website, display a separate link to each category. 
    </div> 

확인 = "예"

+0

나는 그것을 시도했다, 그것은 도움이되지 않았다 – sasori

+0

그리고 나는 당신이 1을 체크하지 않는 것이 사실로 돌아오고 있다고 생각한다. –

관련 문제