Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #--*--coding: utf-8--*--
- import MySQLdb
- import user
- from dbconfig import read_param, game_server
- from premium_user import isPremiumUser
- status, username = user.isAuth()
- premium_account = isPremiumUser()
- if status:
- if premium_account:
- print """<script>
- var sel = document.getElementById("char_select");
- var txt = sel.options[sel.selectedIndex].text;"""
- print """<script>
- function SelectDefault()
- {
- document.getElementById("char_select").options[0].selected=true;
- }
- function sel()
- {
- var sel_elem = document.getElementById("char_select");
- var txt = sel_elem.options[sel_elem.selectedIndex].text;
- //print txt
- }"""
- db_config = game_server()
- db = MySQLdb.connect(**db_config)
- cursor = db.cursor()
- cursor.execute("SELECT char_name from characters WHERE account_name=%s", (username))
- all_characters = cursor.fetchall() #кортеж из кортежей
- all_char = range(len(all_characters)) #range(2) будет [0, 1]
- print "<center>"
- print "<select name=\"char_select\" id=\"char_select\" OnChange=\'sel()\'>"
- j = 0
- for char_name in all_char:
- j+=1
- i = all_characters[char_name][0]
- print "<option value=\"%s\">%s</option>" % (j, i)
- print "</select><br></center>"
- print """<script>SelectDefault();</script>"""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement