I'm trying to get some data from MySql database and to create switch
based on those data, but as an php beginer, I have no clear idea how to
do this. have tryed many options which loked promising, but with limited
success. here are two versions of code:
the 1st one is executing just 1st loaded data, ie: if case is "id_001"
it will print "data for id #001", and will, in case there is nothing in
url like "index.php?action=" print "nothing" as expected. but It will
also print that ugly "nothing" for "id_002", etc...
<?
//just taking something from mysql
$query = "SELECT some_id,some_data FROM modules";
$result = mysql_query ($query) or die ("Query failed ($query)");
list($some_id,$some_data) = mysql_fetch_array($result);
switch ($action)
{
case "$some_id":
print "$some_data";
break;
default:
print "nothing";
}
?>
the 2nd one is executing all I want and "much more"..! it will in case
of "id_003" print "yet another something about #003", but will print
"nothing" (default statement) as much times as I have rows in my mysql
databse...
<?
//just taking something from mysql
$query = "SELECT some_id,some_data FROM modules";
$result = mysql_query ($query) or die ("Query failed ($query)");
while(list($some_id,$some_data) = mysql_fetch_array($result))
{
switch ($action) {
case "$some_id":
print "$some_data";
break;
default:
print "nothing";
}
}
?>
can anyone help me to find the right way to do this? (I have shortened
code (querys) in this post, actualy, this is suposed to load different
pages/scripts...)
tnx
Janko
--
Jan ko?
http://fotozine.org
--