Genixdeae
01-25-2006, 02:31 PM
Ok, I have this function(see below) which is supposed to grab the correct things to display depending on what 'race' is being input. the code to get the function is like this:echo race_commodities(1, 1); //should output Metal, and it does
echo race_commodities(1, 2); //should output Oil, but it doesn't, it puts Metal i'm not sure what's not working, logically to me, it should be working//this first function will helps us grab the names of the commodities depending on the race
function race_commodities($race, $which_comm){
if($race == 1) {//They have chosen humans
$commodity1 = "Metal";
$commodity2 = "Oil";
$commodity3 = "Gas";
$power = "Electricity";
if($which_comm = 1) {//They want to see the first commodity
return $commodity1;
}elseif($which_comm = 2) {//They want to see the second commodity
return $commodity2;
}elseif($which_comm = 3) {//They want to see the third commodity
return $commodity3;
}elseif($which_comm = 4) {//They want to see the power
return $power;
}else{//They want to return a commodity that doesn't exsist
return "Error: Unknown commodity.";
}
}elseif($race == 2) {//They have chosen Chronthos
$commodity1 = "Comm1";
$commodity2 = "Comm2";
$commodity3 = "Comm3";
$power = "Power";
if($which_comm = 1) {//They want to see the first commodity
return $commodity1;
}elseif($which_comm = 2) {//They want to see the second commodity
return $commodity2;
}elseif($which_comm = 3) {//They want to see the third commodity
return $commodity3;
}elseif($which_comm = 4) {//They want to see the power
return $power;
}else{//They want to return a commodity that doesn't exsist
return "Error: Unknown commodity.";
}
}elseif($race == 3) {//They have chosen Prostiegans
$commodity1 = "Protons";
$commodity2 = "Electrons";
$commodity3 = "Neutrons";
$power = "Particle Conductor";
if($which_comm = 1) {//They want to see the first commodity
return $commodity1;
}elseif($which_comm = 2) {//They want to see the second commodity
return $commodity2;
}elseif($which_comm = 3) {//They want to see the third commodity
return $commodity3;
}elseif($which_comm = 4) {//They want to see the power
return $power;
}else{//They want to return a commodity that doesn't exsist
return "Error: Unknown commodity.";
}
}else{//They have some how chosen a race that doesn't exsist
$commodity1 = "Error";
$commodity2 = "Error";
$commodity3 = "Error";
$power = "Error";
if($which_comm = 1) {//They want to see the first commodity
return $commodity1;
}elseif($which_comm = 2) {//They want to see the second commodity
return $commodity2;
}elseif($which_comm = 3) {//They want to see the third commodity
return $commodity3;
}elseif($which_comm = 4) {//They want to see the power
return $power;
}else{//They want to return a commodity that doesn't exsist
return "Error: Unknown commodity.";
}
}
}
I am completly confused by this and odds are it's something really simple, need more info jus let me know.
echo race_commodities(1, 2); //should output Oil, but it doesn't, it puts Metal i'm not sure what's not working, logically to me, it should be working//this first function will helps us grab the names of the commodities depending on the race
function race_commodities($race, $which_comm){
if($race == 1) {//They have chosen humans
$commodity1 = "Metal";
$commodity2 = "Oil";
$commodity3 = "Gas";
$power = "Electricity";
if($which_comm = 1) {//They want to see the first commodity
return $commodity1;
}elseif($which_comm = 2) {//They want to see the second commodity
return $commodity2;
}elseif($which_comm = 3) {//They want to see the third commodity
return $commodity3;
}elseif($which_comm = 4) {//They want to see the power
return $power;
}else{//They want to return a commodity that doesn't exsist
return "Error: Unknown commodity.";
}
}elseif($race == 2) {//They have chosen Chronthos
$commodity1 = "Comm1";
$commodity2 = "Comm2";
$commodity3 = "Comm3";
$power = "Power";
if($which_comm = 1) {//They want to see the first commodity
return $commodity1;
}elseif($which_comm = 2) {//They want to see the second commodity
return $commodity2;
}elseif($which_comm = 3) {//They want to see the third commodity
return $commodity3;
}elseif($which_comm = 4) {//They want to see the power
return $power;
}else{//They want to return a commodity that doesn't exsist
return "Error: Unknown commodity.";
}
}elseif($race == 3) {//They have chosen Prostiegans
$commodity1 = "Protons";
$commodity2 = "Electrons";
$commodity3 = "Neutrons";
$power = "Particle Conductor";
if($which_comm = 1) {//They want to see the first commodity
return $commodity1;
}elseif($which_comm = 2) {//They want to see the second commodity
return $commodity2;
}elseif($which_comm = 3) {//They want to see the third commodity
return $commodity3;
}elseif($which_comm = 4) {//They want to see the power
return $power;
}else{//They want to return a commodity that doesn't exsist
return "Error: Unknown commodity.";
}
}else{//They have some how chosen a race that doesn't exsist
$commodity1 = "Error";
$commodity2 = "Error";
$commodity3 = "Error";
$power = "Error";
if($which_comm = 1) {//They want to see the first commodity
return $commodity1;
}elseif($which_comm = 2) {//They want to see the second commodity
return $commodity2;
}elseif($which_comm = 3) {//They want to see the third commodity
return $commodity3;
}elseif($which_comm = 4) {//They want to see the power
return $power;
}else{//They want to return a commodity that doesn't exsist
return "Error: Unknown commodity.";
}
}
}
I am completly confused by this and odds are it's something really simple, need more info jus let me know.