You are here: two-dimensional switch statement? « PHP Programming Language « IT news, forums, messages
two-dimensional switch statement?

Posted by Miyagi on 08/22/07 18:33

I have a bunch of conditions in which to determine different types of
questions to ask in a survey I am constructing.
Just was wondering if anybody has used a two-dimensional switch
statement. If this works, is this an efficient coding method or would
anybody else have another way around this?

$type = enters _POST as (employee, client, or peer)
$visit = enters _POST as ( 0 or 1 )
$userage = enters _POST as ( 1, 2, 3, or 4)
$ip is the IP address of the user

function determineUser($type, $userage, $ip, $visit)
{

switch ($type){
case 'employee':
switch ($userage){
case '1':
case '2': if($visit){$surveyType=1;}else{$surveyType=2;} break;
case '3':
case '4': $surveyType=3; break;
case 'client': if($visit){$surveyType=4;}else{$surveyType=5;}
break;
case 'peer': if($visit){$surveyType=6;}else{$surveyType=7;} break;
}

$query = "INSERT INTO user(userip, userage, idsurvey)
VALUES('$ip','$userage','$surveyType')";
mysql_query($query);

return (getUserId($ip));
}

Thanks.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация