R
Rich21
Guest
I'm trying to make a depth chart for a sports game I'm trying to make. I don't have it in front of me but the code looks something like this:
$query = "SELECT Team, $pos1, $pos2, $pos3, $pos4 FROM depth WHERE Team = $teamID";
$result = mysql_query($query);
$record = mysql_fetch_array($result);
// All the above works fine
$output1 = $record[$pos1];
$output2 = $record[$pos2];
$output3 = $record[$pos3];
$output4 = $record[$pos4];
$output comes out null whether or not the field is. If I try $output = $record['$pos1'];(with apostrophes) it will just echo what $pos1 is(ie if $pos1 = C, then it will just echo "C") not what is in the field itself. Is it possible to do what I'm trying? Is there a more efficient way to do it?
Any help is appreciated. Thank you.
$query = "SELECT Team, $pos1, $pos2, $pos3, $pos4 FROM depth WHERE Team = $teamID";
$result = mysql_query($query);
$record = mysql_fetch_array($result);
// All the above works fine
$output1 = $record[$pos1];
$output2 = $record[$pos2];
$output3 = $record[$pos3];
$output4 = $record[$pos4];
$output comes out null whether or not the field is. If I try $output = $record['$pos1'];(with apostrophes) it will just echo what $pos1 is(ie if $pos1 = C, then it will just echo "C") not what is in the field itself. Is it possible to do what I'm trying? Is there a more efficient way to do it?
Any help is appreciated. Thank you.