Jump to content

[SOLVED] Creating an if statment made out of variables.


pocobueno1388

Recommended Posts

What I am trying to do is create an if statement that is made out of purely variables, but I am having trouble getting it to work properly.

 

Here is my code, I will comment through it to help you understand:

<?php
   
   //I select the fields I am dealing with from the database.
   $funInfo = mysql_query("SELECT discipline, height FROM horses WHERE horseID='$horseID'");
   $f = mysql_fetch_assoc($funInfo);

   //Here are the two variables I am working with
   $stat = trim($split_first[0]); //echos out "discipline"
   $split_first[1]; //This variable got it's value earlier in the script. It echos out "== 'western' "

   //Build the IF statment
   if ($f[$stat].$split_first[1]){
       echo 'The statement is true!';
    }
?>

 

So I am basically trying to get this line:

if ($f[$stat].$split_first[1]){

 

to be read as an if statement by PHP that should look something like this:

if (english == 'western'){

 

But for some reason it is always returning true....and it shouldn't.

 

Any advice on how to build this if statement with variables would be greatly appreciated. Thanks xD

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.