antonyf
02-11-2014, 11:18 AM
Hi, I have to columns in a database that i would like to pull the row if either of the columns email matches a email in a comma seperated string..
foreach(array_values($nlines) as $value){ // here $value is a comma separated string..
$value = str_replace('"', '', $value);
$value = str_replace('\'', '', $value);
$value = str_replace($seperators, ',', $value);
$exists = mysql_query("SELECT email, work_email FROM `contacts` WHERE `userid` = '".$User->id."'"); //userid predetermined id..
while($row=mysql_fetch_array($exists)) {
if(strpos(strtolower(str_replace(',',' ',$value)), strtolower($row['email'])) === false && strpos(strtolower(str_replace(',',' ',$value)), strtolower($row['work_email'])) === false)
{
$nnmu = explode(',', $value);
$totnum = count($nnmu);
if($totnum == $num){ // here number is a value brought forward from another function ..
$newline .= trim($value).','.$User->id."\n";
} else {
if (preg_match('/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/si', $value))
{
$nval = $num - $totnum;
$valfront = split_nth(implode(',',$arr_head),',', $nval); // to match the lines i got he difference and joined to the value.. otherwise it causes complications with my overall function if lines are not equal lengths..
$string = preg_replace('~[^,]~','',trim($valfront[0]));
$newline .= trim($value).',,'.$string.',,,'.$User->id."\n";
}
}
}
}
}
foreach(array_values($nlines) as $value){ // here $value is a comma separated string..
$value = str_replace('"', '', $value);
$value = str_replace('\'', '', $value);
$value = str_replace($seperators, ',', $value);
$exists = mysql_query("SELECT email, work_email FROM `contacts` WHERE `userid` = '".$User->id."'"); //userid predetermined id..
while($row=mysql_fetch_array($exists)) {
if(strpos(strtolower(str_replace(',',' ',$value)), strtolower($row['email'])) === false && strpos(strtolower(str_replace(',',' ',$value)), strtolower($row['work_email'])) === false)
{
$nnmu = explode(',', $value);
$totnum = count($nnmu);
if($totnum == $num){ // here number is a value brought forward from another function ..
$newline .= trim($value).','.$User->id."\n";
} else {
if (preg_match('/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/si', $value))
{
$nval = $num - $totnum;
$valfront = split_nth(implode(',',$arr_head),',', $nval); // to match the lines i got he difference and joined to the value.. otherwise it causes complications with my overall function if lines are not equal lengths..
$string = preg_replace('~[^,]~','',trim($valfront[0]));
$newline .= trim($value).',,'.$string.',,,'.$User->id."\n";
}
}
}
}
}