Issue with getting values from MySQL databse using array

arandadjoeann

New Member
Hey guys so I am trying to get values from a database based on an array of firstname's, lastnames's and email's.Here is the code:\[code\]$sesfirst = $_SESSION['CSVRfirstnames'];$seslast = $_SESSION['CSVRlastnames'];$sesemail = $_SESSION['CSVRemails'];$Activeusername = $_SESSION['myusername'];$j = 0;$i = 0;$k = 0;unset($_SESSION['CSVRfirstnames'], $_SESSION['CSVRlastnames'], $_SESSION['CSVRemails']); for ($k; $k < count($sesfirst); $k++){ $sql = "SELECT firstname, lastname, email,username,status FROM csvdata WHERE memberview =:username AND firstname =:sesfirst AND lastname =:seslast AND email = :sesemail ORDER BY lastname"; $sth= $DBH->prepare($sql); $sth->execute(array(':username' => $Activeusername,':sesfirst' => $sesfirst[$k],':seslast' => $seslast[$k],':sesemail' => $sesemail[$k])); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $csvfirst = $row; $csvfirstname = $csvfirst['firstname']; $csvlastname = $csvfirst['lastname']; $csvemail = $csvfirst['email']; $csvstatus = $csvfirst['status']; if ($csvstatus != "Non-Active - No Longer Employed"){ $Rusernames[$k] = $csvfirst['username']; $i++; echo " <tr> <td> $csvfirstname </td> <td> $csvlastname </td> <td> $csvemail </td> <td> $i </td> </tr> "; } }}$_SESSION['rusernames'] = $Rusernames;\[/code\]so When I run this, for some reason some of the values that are in the database will come up if one of the words match either the firstname lastname and email. I need it to show up if only the firstname lastname and email match
 
Back
Top