I have always had trouble with trying to write these from scratch. The
code below is essentially what I have been working on, but it never
stops looping. What am I missing here?

<?php

$teams=array(
'Reds',
'Browns',
'Bengals',
'Cavaliers',
'Blue Jackets',
'Indians'
);

$unique=false;
$newTeam=$_POST['newTeam'];

function checkDuplicate($value){
        global $teams;
        $count=0;
        //do query here, return an array
        for($i=0; $i<count($teams); $i++){
                if($value==$teams[$i]){
                        $count++;
                        }
                }
        if($count == 0){
                //no matches
                return true;
                }
        else {
                //there are matches
                return false;
                }
        }
        
while(!$unique){
        $check=checkDuplicate($newTeam);
        if($check){ $unique=true; } else { $unique=false; }
        }

?>

--
Randal Rust
R.Squared Communications
www.r2communications.com
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to