On Sat, Dec 18, 2010 at 11:44 PM, Robert Cummings <[email protected]> wrote:
> On 10-12-19 12:17 AM, Ethan Rosenberg wrote:
>>
>> Dear List -
>>
>> Thanks to all for your EXCELLENT comments. I definitly agree that
>> goto is a command to be avoided at all costs.
>
> Closed-minded drivel (or you're buttering up the popular opinion crowd). A
> better approach is that goto should be used with caution.
>
> As for doing your homework for you... ummm no thanks. You should take the
> time to do the exercise so you gain the benefit of experience.
I would have thought school would have been out on account of Christmas and all.
In any event, here's my rewrite:
switch (true)
{
case isset($_POST['Site']) && trim($_POST['Site']) != '':
$sql1 = $sql1 . "site = '$ste'";
break;
case isset($_POST['MedRec'])&& trim($_POST['MedRe']) != '':
$sql1 = $sql1 . "MedRec = '$req'";
break;
// ...
default:
if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' )
{
if ($_REQUEST["Sex"] == "0")
$sex = 'Male';
else
$sex = 'Female';
$sql1 = $sql1 . " = '$sex'";
$sexdone = 1;
}
if(isset($_POST['Hx'])&& trim($_POST['Hx']) != '')
{
$sql1 = $sql1 . "Hx = '$hx'";
$done = 1;
}
}
You could also do an if / else if / else if / ... / else.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php