Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2003, 12:25 AM
geniuscrew's Avatar
geniuscrew geniuscrew is offline
 
Join Date: Nov 2001
Location: UK
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Radio buttons help

Hey

I'm trying to put data into a database [doh] but can't retrieve it. Basically if the button is checked it puts the value "1" in the database.

If it's not checked, well that's where I'm hoping someone can help lol

I mean when it comes to editting it, it should already be checked but it isn't. And when I do update, something totally weird happens.

Thanks in advance.

If it helps, I'm not using the standard Vbulletin $opt thing
Reply With Quote
  #2  
Old 02-23-2003, 05:48 AM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so if it's checked put a 1 in the db and if it's not put a 0 in the db? is that what you want?
Reply With Quote
  #3  
Old 02-24-2003, 05:35 AM
geniuscrew's Avatar
geniuscrew geniuscrew is offline
 
Join Date: Nov 2001
Location: UK
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll explain a little more - I'm trying to customize Bitsys's battle hack, the "Races" part of it.

Now i'm trying to make a Race one gender only [female]. So when adding a race, you check the button if you want it to be female only. And it's inserting fine into the database [it shows 1- 0 is default]

On coming to the main page of the races, it won't show that a race is female, so somehow, I need to retrive that "1" from the database.

Then when I reselect it and update the races, the race moves into the "Unknown" Alignment, but I guess that's a different problem.
Reply With Quote
  #4  
Old 02-24-2003, 10:03 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

look a bit at member.php
there you can see how the radiobuttons are decoded
Reply With Quote
  #5  
Old 02-24-2003, 04:18 PM
geniuscrew's Avatar
geniuscrew geniuscrew is offline
 
Join Date: Nov 2001
Location: UK
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can? I just looked an couldn't find anything :/

Also I can't use the makeyesnocode because It might screw it up >.<
Reply With Quote
  #6  
Old 02-24-2003, 04:29 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

for example this part of code:
PHP Code:
  if ($bbuserinfo[cookieuser]) {
    
$cookieuserchecked="checked";
    
$cookieusernotchecked="";
  } else {
    
$cookieuserchecked="";
    
$cookieusernotchecked="checked";
  } 
and in the template then:
Code:
<input type=radio value=0 $cookieusernotchecked>No <input type=radio value=1 $cookieuserchecked>Yes
Reply With Quote
  #7  
Old 02-24-2003, 04:39 PM
geniuscrew's Avatar
geniuscrew geniuscrew is offline
 
Join Date: Nov 2001
Location: UK
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ohhhh that part -

Ich werde dass versuchen [hope that makes sense, not done German for a year ]
Reply With Quote
  #8  
Old 02-24-2003, 04:56 PM
geniuscrew's Avatar
geniuscrew geniuscrew is offline
 
Join Date: Nov 2001
Location: UK
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lol this is what I've managed to add, but it's not working

PHP Code:
// ###################### addraces #######################




if ($action=="addraces") {
  
$alignments=$DB_site->query("SELECT * FROM rpg_alignment ORDER BY name");
  while (
$align $DB_site->fetch_array($alignments)) {
    if(
$align[id] == $alignmentid) {
        
$alignoptions .= "<option value=\"$align[id]\" SELECTED>$align[name]</option>\n";
    } else {
        
$alignoptions .= "<option value=\"$align[id]\">$align[name]</option>\n";
    }
  }

if (
$racesex) {
    
$racesexchecked="checked";
    
$racesexnotchecked="";
  } else {
    
$racesexchecked="";
    
$racesexnotchecked="checked";
  }

        echo 
"<center>The inputs are as follows: <b>[name] [alignmentid] [regularattack] [regular 

defense] [magicattack] [magicdefense] [speed] [evade] [male/female]</b></center>"
;
  
doformheader("rpgadmin","doaddraces");
  
maketableheader("Add Races");
  echo 
"<tr class='firstalt'><td><ul>\n\n";
  
$nr 0;
  while (
$nr <= 7) {
        echo 
"<ul><li><input type=text name=\"name[]\" size=30 value=\"\"> <select 

name=\"alignmentid[]\" length=10>
$alignoptions</select> <input type=text name=\"regatt[]\" size=2 

value=\"\"> <input type=text name=\"regdef[]\" size=2 value=\"\"> <input type=text 

name=\"magicatt[]\" size=2 value=\"\"> <input type=text name=\"magicdef[]\" size=2 value=\"\"> 

<input type=text name=\"speed[]\" size=2 value=\"\"> <input type=text name=\"evade[]\" size=2 

value=\"\"> <input type=radio name=\"racesex[]\" value=0 
$racesexnotchecked>Default <input 

type=radio name=\"racesex[]\" value=1 
$racesexchecked>Female Only
 </ul></li>"
;
  
$nr++;
  }
  echo 
"</ul>\n</td></tr>\n";
  
doformfooter("Add Races");
}

// ###################### doaddraces #######################

if ($HTTP_POST_VARS['action']=="doaddraces") {

  while (list(
$key,$val)=each($name) AND list($key,$val2)=each($alignmentid) AND 

list(
$key,$val3)=each($regatt) AND list($key,$val4)=each($magicatt) AND 

list(
$key,$val5)=each($magicdef) AND list($key,$val6)=each($regdef) AND 

list(
$key,$val7)=each($speed) AND list($key,$val8)=each($evade) AND 

list(
$key,$val12)=each($racesex)) {
    if(!empty(
$val)) {
    
$aligninfo $DB_site->query_first("SELECT name FROM rpg_alignment WHERE id='$val2'");
      
$DB_site->query("INSERT INTO `rpg_race` (`raceid`, `name`, `alignmentid`, `regatt`, 

`regdef`,`magicatt`,`magicdef`,`speed`, `evade`, `alignment`, `racesex`) VALUES ('', 

'"
.addslashes($val)."', '$val2', '$val3', '$val4','$val5','$val6', '$val7', '$val8', 

'"
.addslashes($aligninfo[name])."', '$val12')");
    }
  }

  echo 
"<p>Races Added!</p>";
  
$action="editraces";
}

// ###################### doraces #######################

if ($HTTP_POST_VARS['action']=="doraces") {
  
$alignments $DB_site->query("SELECT name, id FROM rpg_alignment ORDER BY id");
  while(
$align $DB_site->fetch_array($alignments)) {
    
$thisid $align[id];
    
$alignarray[$thisid] = $align[name];
  }
  while (list(
$key,$val)=each($name) AND list($key,$val2)=each($alignmentid) AND 

list(
$key,$val3)=each($regatt) AND list($key,$val4)=each($regdef) AND 

list(
$key,$val5)=each($magicatt) AND list($key,$val6)=each($magicdef) AND 

list(
$key,$val7)=each($speed) AND list($key,$val8)=each($evade) AND 

list(
$key,$val12)=each($racesex)) {

    
$DB_site->query("UPDATE rpg_race SET 

name='"
.addslashes($val)."',alignmentid='".addslashes($val2)."',regatt='$val3',regdef='$val4',mag

icatt='
$val5', magicdef='$val6', speed='$val7', evade='$val8', alignment='$alignarray[$val2]', 

racesex='
$val12' WHERE raceid='$key'");
  }
  echo 
"<p>Races updated!</p>";
  
$action="editraces";

Please help before I go crazee

Thanks
Reply With Quote
  #9  
Old 02-24-2003, 08:02 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm, it looks right, are you sure $racesex is defined befor it's used in the ifclause?


also yes your german was correct
Reply With Quote
  #10  
Old 02-24-2003, 09:16 PM
geniuscrew's Avatar
geniuscrew geniuscrew is offline
 
Join Date: Nov 2001
Location: UK
Posts: 346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the reply - no Xenon, that's the first time where I've used it

So where do I put the ifclause? Towards the end?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:02 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04444 seconds
  • Memory Usage 2,299KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete