I want to implement the following code via array
:
if ($z=='one'){$result = mysql_query( " SELECT * FROM table1", $link);}
if ($z=='two'){$result = mysql_query( " SELECT * FROM table2", $link);}
My try is here: (full code)
$z = $_GET["z"];
$link = mysql_connect("localhost","root","");
mysql_select_db("DBname",$link);
function one(){
$result = mysql_query( " SELECT * FROM table1");
return $result;
}
function two(){
$result = mysql_query( " SELECT * FROM table2");
return $result;
}
$arr=array ('one'=>"one",'two'=>"two");
$result=$arr[$z]();
while($end = mysql_fetch_assoc($result)) {
$end["col1"];
$end["col2"];
$end["col3"];
}
mysql_close($link);
Why this code does not work ??
Tnx friends