Switch generally analyses one variable, if its not true it goes to the next one...
If you are intent on using a switch (you may have your reasons) then I would set something in the url:
t for "type", v for value;
<a href="view_files.php?t=1v='.$array['id'].'">'.$array['name'].'</a>
....
$v=(int)$_GET['v']; //make sure its an int!
Then analyse $t in your switch:
PHP Code:
switch((int)$_GET['t']) //make sure its an int!
{
case (1):
$query = "SELECT name, type, size, content ".
"FROM mergers ".
"WHERE id = '$v'";
echo $query;
break;
case (2):
$query = "SELECT name, type, size, content ".
"FROM centralised_archive.mergers ".
"WHERE id = '$v'";
echo $query;
break;
}
Then do a "default" if the no. isnt recognised
Switch generally analyses one variable, if its not true it goes to the next one... So its checking to see if $t==1 or goes off to next one, and so on till it gets to the default.
Paul
EDIT
If its a monster switch you might want to isolate the bit thats changing:
PHP Code:
case (1):
$querybit = "FROM mergers ";
break;
case (2):
$querybit = "FROM centralised_archive.mergers ";
break;
}
$query = "SELECT name, type, size, content ".
$query.=$querybit;
$query.="WHERE id = '$v'";
echo $query;
Hope that helps you...
Bookmarks