I've got an issue with a function where it's returning data from the first if() statement as opposed to the secondary if() statement in a function, please see below.
function training($type,$tid)
{
if($type = "id") {
$query = mysql_query("SELECT * FROM trainroster WHERE DATE = CURDATE()");
if (mysql_num_rows($query) == 1) {
$array = mysql_fetch_array($query);
$id=$array['TID'];
}
else { $id = "1"; }
return $id;
}
else if($type = "topic"){
$query = mysql_query("SELECT * FROM trainroster WHERE TID='$tid'");
$array = mysql_fetch_array($query);
$topic = $array['TOPIC'];
return $topic;
}
}
Which is being called like this:
$training = $connection->training("topic",$row['TID']);
When the function is called it's returning the $id as opposed to the $topic even though I'm setting the $type variable to "topic".
Any help greatly appreciated, cheers!