vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Radio buttons help (https://vborg.vbsupport.ru/showthread.php?t=49232)

geniuscrew 02-23-2003 12:25 AM

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

mr e 02-23-2003 05:48 AM

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?

geniuscrew 02-24-2003 05:35 AM

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.

Xenon 02-24-2003 10:03 AM

look a bit at member.php
there you can see how the radiobuttons are decoded :)

geniuscrew 02-24-2003 04:18 PM

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

Also I can't use the makeyesnocode because It might screw it up >.<

Xenon 02-24-2003 04:29 PM

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

geniuscrew 02-24-2003 04:39 PM

Ohhhh that part -

Ich werde dass versuchen [hope that makes sense, not done German for a year ;)]

geniuscrew 02-24-2003 04:56 PM

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

Xenon 02-24-2003 08:02 PM

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


also yes your german was correct :)

geniuscrew 02-24-2003 09:16 PM

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?

Xenon 02-24-2003 09:25 PM

nope, not at the end, the position is alright there but you have to add something before.

where ist this setting stored?
you have to read it out somewhere befor you can work with it.

like in member.php it's read out of the $bbuserinfo array

geniuscrew 02-24-2003 09:43 PM

The code above is part of a file in the admin panel - I think that's where it's messing up.

However in theory members will be able to update their stats through member.php

While we're at coding, where's the code that gives someone with "X" posts their next usertitle? :D.

Thanks


All times are GMT. The time now is 03:03 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02286 seconds
  • Memory Usage 1,786KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (12)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete