matching flat file names with databse names
| From: | rdkurth at starband dot net | Date: | Sat, 24 Aug 2002 08:18:12 +0000 |
| Subject: | matching flat file names with databse names | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-113914@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
$fp = fopen($file,"r");
while (!feof ($fp)) {
$buffer = fgets($fp,4096);
if(strstr($buffer,'@www.') === false){
$other[]= $buffer;
}else{
$www[] = $buffer;
}}
fclose ($fp);
for($i = 0; $i < count($other); $i++){
$userwww = $www[$i];
$user_name =substr($userwww,0,strpos($userwww,'@'));}
<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'];
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