ptmuldoon
03-21-2007, 02:42 AM
Has anyone every used a switch to decide which table a query should use?
I'm experimenting a little, and I think the following should correct?
$sql = 'SELECT * FROM games';
$gamedata = mysql_query($sql);
$row = mysql_fetch_assoc($gamedata);
$game_type = $row["type"];
switch($game_type){
case 'R1': $table = 'table1';
break;
case 'R2': $table = 'table2';
break;
case 'R3': $table = 'table3';
break;
}
$sql = "SELECT adjacencies FROM $table WHERE id = '$from_country'";
I'm experimenting a little, and I think the following should correct?
$sql = 'SELECT * FROM games';
$gamedata = mysql_query($sql);
$row = mysql_fetch_assoc($gamedata);
$game_type = $row["type"];
switch($game_type){
case 'R1': $table = 'table1';
break;
case 'R2': $table = 'table2';
break;
case 'R3': $table = 'table3';
break;
}
$sql = "SELECT adjacencies FROM $table WHERE id = '$from_country'";