2011-08-23 4 views
2

나는 나라를 시작으로 원하는 곳의 사용자 입력을 받아들이는 스크립트를 프로그램하려고합니다. 그런 다음 사용자의 의견을 수렴하여 국가에 속한 국가의 목록을 업데이트하십시오.이 도시는 주 및 국가에 있습니다.mysql 쿼리에서 psp/python/html의 double loop를 사용합니다.

저는 제 프론트 엔드에 파이썬/psp를 사용하고 프론트 엔드에는 html을 사용하고 있습니다. 이 페이지 업데이트가 내 사이트에서 작동하도록하는 데 문제가 있습니다. 누구든지 도와 줄 수 있습니까?

cursor.execute("select * from location where country='%s'" % record[0]) or die(mysql_error()) 

     ^

IndentationError: expected an indented block 

내 구문이 잘못 :

<div id="content"> 


<p> 
Where would you like to go? 
</p> 
<form method="post" action="http://localhost/list2.psp"> 
Places to go: 
<select name = "location"> 
<% 
cursor.execute("select distint country from location") or die(mysql_error()) 
result = cursor.fetchall() 
for record in result: 
cursor.execute("select * from location where country='%s'" % record[0]) or die(mysql_error()) 
result2 = cursor.fetchall() 
%> 

<optgroup label="<%=record[0]%> 
<% 

for record2 in result2: 
%> 

<option value="<%= record2[0] %>"><%= record[1] %>, <%= record[2]%>, <%= record[3]%></option> 

<% 
print 'hi' 
%> 

</optgroup> 
</select> 
<br> 


<input type="submit" value="Search">` 
</form> 
</div> 

그것은 나를 내 웹 페이지에서이 오류 준다?

+0

PSP? 정말? 와우. –

답변

0

나는 파이썬 서버 페이지에 대해 들어 본 적이 없다. 와우. 어쨌든 Python indentation matters에서 들여 쓰기는 C 스타일의 중괄호를 대신 할 수 있습니다.

for 루프에서 루프에 속한 모든 항목이 같은 수준에서 들여 쓰기되어야합니다.

+1

들여 쓰기는 4 개의 공백이어야하며, ** 탭이 아니어야합니다. –

관련 문제