matching flat file names with databse names

From: Date: Sat, 24 Aug 2002 18:21:25 +0000
Subject: matching flat file names with databse names
Groups: php.general 
Request: Send a blank email to php-general+get-113959@lists.php.net to get a copy of this message
I have a flat file that has some e-mail address in them so I am pulling them out with the script below then using substr and strpos to return only the username in front of the @. Then I have a mysql database that has usernames in it. What I want to do is to compare the usernames that are in the flat file to the usernames in the database and if they match I want to add the selected switch in a drop down box on every user that matches. I seam to be a little lost with the code though. Or maybe I am going at this all wrong //Pulling data out of flat file// $fp = fopen($file,"r"); while (!feof ($fp)) { $buffer = fgets($fp,4096); if(strstr($buffer,'@www.') === false){ $user[] = $buffer; } fclose ($fp); for($i = 0; $i < count($other); $i++){ $users = $user[$i]; //this is the names I want to compare to the database names /these names have @www.domain.com need to strip that of so I just have the name $user_name =substr($users,0,strpos($users,'@'));} //pulling the database names out// <SELECT MULTIPLE NAME="userrecipients" SIZE="6"> <OPTION VALUE="">--- select local users from list ---</OPTION> <? $query="Select * from users where domname='$domname'"; $result = safe_query($query); while ($row = mysql_fetch_array($result)){ $name = $row['username']; //This is where Want to add the names if the database names match the flat file names I want it to add the selected switch so it is highlighted if($user_name==$name){?> <option value="<?echo$name?>" selected><?echo$name?></option> <?}else{?> <OPTION VALUE="<?echo$name?>"><?echo$name?></OPTION> <?}}?> </SELECT> -- Best regards, rdkurth mailto:rdkurth@starband.net

« previous php.general (#113959) next »