2014-07-17 2 views
0

안녕하세요 거기에 체크 박스가있는 확인란 (특정 ID) 및 확인란을 클릭하면, 더 많은 질문 (기본적으로 텍스트 필드) 팝업됩니다 쪽으로. 그러나 일부 체크 박스에는 같은 질문이 있습니다. 그런 다음 데이터를 mysql 데이터베이스에 저장합니다. 그리고 나는 그것을 나중에 보여주고있다. 그리고 질문 : 어떻게 현재의 ID 및 원하는 텍스트 필드에만 게시 할 스위치 문 또는 일부 알고리즘을 만드는 방법입니다.일부 팝업 질문 반복으로 PHP/MySQL의 양식

FO 그림 :

0-100kg (Checkbox1) 

- Which material? (textfield with name=material) 

- Circle radius? (textfield with name=radius) 

100-500kg (Checkbox2) 

- Which material? (textfield with name=material) 

- Circle radius? (textfield with name=radius) 

500-1000kg (Checkbox3) 

- Which material? (textfield with name=material) 

- Circle radius? (textfield with name=radius) 

- Roots? (textfield with name=roots) 

번호 :

형태 :

<label class="collapse" for="100to500"><b>100 - 500kg</b></label> 
<input id="100to500" type="checkbox" name="100to500"> 
<div><br> 
Which material? <input type="text" name="material"/><br> 
Circle radius? <input type="text" name="radius"/><br></div> 

<label class="collapse" for="500to1000"><b>500 - 1000kg</b></label> 
<input id="500to1000" type="checkbox" name="500to1000"> 
<div><br> 
Which material? <input type="text" name="material"/><br> 
Circle radius? <input type="text" name="radius"/><br> 
Roots? <input type="text" name="roots"/><br></div> 

PHP :

기억 변수 :

$material=mysql_real_escape_string($_POST['material']); 
$radius=mysql_real_escape_string($_POST['radius']); 
$roots=mysql_real_escape_string($_POST['roots']); 

$100to500 = isset($_POST['100to500']) ? $_POST['100to500'] : '0'; 
$500to1000= isset($_POST['500to1000']) ? $_POST['500to1000'] : '0'; 
,

나는 어떻게 든 동일한 ID (데이터베이스 행)에 모든 데이터를 저장하고 클릭 한/채워진 데이터 만 저장할 것이라고 accopmlish하려고합니다. 나는 어리석은 설명이지만 2 주 동안 만 PHP를 사용하고 있으므로 완전한 멍청이 임.

고맙습니다.

+0

하지 귀하의 질문에 직접 대답을하지만 보인다 당신이 2 개의 질문 텍스트 필드 + 체중 선택기를 갖는 것이 더 낫다면. 이상하게 각 무게 종류의 밑에 일련의 중복 질문이있는 대신에. –

+0

좋아, 나는 누군가가 downvoted 것을 본다, 당신이이 게시물이 불필요하다고 생각한다면 당신은 적어도 나를 리드 할 수있다. – rudyherehello

+0

네, 저에게도 더 논리적으로 보입니다. 답변 해 주셔서 감사합니다. – rudyherehello

답변

0

먼저, 체중 카테고리의 여러 섹션을 허용하지 않는다고 가정합니다. 이 경우 select 태그를 사용하여 사용자 입력을 제한하십시오. 는 둘째 당신이이

[dropdown list/ select] 
- Which material? (textfield with name=material) 
- Circle radius? (textfield with name=radius) 
- Roots? (textfield with name=roots) 
- Q4 e.t.c. 

필터처럼 모든 체급에 대한 모든 가능한 질문을 보이는 모든 UNIQUE 질문 목록을 만들도록 레이아웃 설정합니다.

마지막으로 현재 선택한 가중치에 따라 각 질문을 표시하거나 숨기려면 javascript를 사용하십시오. php를 사용하여 웹 페이지의 UI를 "동적으로"변경할 수는 있지만, 다소 바보 같으며 javascript보다 효율이 떨어집니다.

결과 양식에서 정보를 추출하는 것은 매우 쉬운 것입니다 및 가능한 중복 텍스트 필드 아이디/이름 여기

미니 샘플의 제공하지 않습니다 : http://jsfiddle.net/Nn4zR/1/

+0

오우 이제 알겠습니다. 정말 고맙습니다! – rudyherehello