The Arcive of vBulletin Modifications Site. |
|
|
#1
|
||||
|
||||
|
The score grabbing works, but now I need the the values in the "gscore,sscore,hscore and rscore" fields
![]() So far, they return: gscore sscore hscore rscore I am not sure what type of field they should be (I have them set as INT ), and they are a point value, with gscore being 4 and sscore being 1...This code is what needs to be modified to get the value (everything else works )![]() Code:
$score = $DB_site->query_first("SELECT '$whichscore' FROM *tablename*_questions WHERE qid='$theqid'");
if ($bbuserinfo['usergroupid']==2)
{
$DB_site->query("UPDATE user SET question1='$theqid',score1='$score[$whichscore]' WHERE userid='$bbuserinfo[userid]'");
}
![]() Satan |
|
#2
|
||||
|
||||
|
Please can anyone help?
I really need to get this finished... Satan |
|
#3
|
||||
|
||||
|
Quote:
PHP Code:
If on the other-hand, $whichscore IS a variable, then I would do the code like this: PHP Code:
![]() p.s. I always break out of quotes when calling variables, just for my own piece of mind. I know you don't have to, but I do unless I'm required to not do it. |
|
#4
|
||||
|
||||
|
Aha thanks...
Yes $whichscore is a earlier defined variable, via this code: Code:
if ($answer==$ganswer) {
$whichscore = 'gscore';
}elseif ($answer==$sanswer) {
$whichscore = 'sscore';
}elseif ($answer==$hanswer) {
$whichscore = 'hscore';
}else{
$whichscore = 'rscore';
}
![]() Thanks - I'll try this ![]() Satan |
|
#5
|
||||
|
||||
![]() Unfortunately the code still returns "gscore" , "hscore", "sscore" and "rscore" ![]() Satan |
|
#6
|
||||
|
||||
|
Quote:
I may be seeing things strangely, but if g, s, h, and rscore are all variables, shouldn't they be prefixed with "$"? Like this? PHP Code:
So assuming that: PHP Code:
|
|
#7
|
||||
|
||||
|
Hmm...I never thought of that - I shall try, thanks
![]() ![]() Satan |
|
#8
|
||||
|
||||
|
np...lemme know.
|
|
#9
|
||||
|
||||
|
Ok...That didnt work...
But then I had an idea - Why query the database for "$whichscore" if the score value is already defined - So I was thinking: Code:
if ($answer == $ganswer){
$score = $gscore;
} elseif ($answer == $sanswer){
$score = $sscore;
} elseif ($answer == $hanswer){
$score = $hscore;
} else {
$score = $rscore;
}
$gscore = 4;
$hscore = 3;
$rscore = 2;
$sscore = 1;
if ($bbuserinfo['usergroupid'] == 2){
$DB_site->query("UPDATE user SET question1 = '"
.$theqid
."', score1 = '"
.$score ."'
WHERE userid = '"
.$bbuserinfo[userid]."'");
}
![]() Edit: It didn't work ![]() Satan |
|
#10
|
||||
|
||||
|
Ah...
If the answer is a numerical value, $answer returns the numerical value of that answer (i.e. if the first answer was 93, $answer returns 93) If the answer is a non-numerical value, $answer returns 0 ![]() Satan |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|