I'm having trouble with my code. What I would like it to do is to check to see if the first set of criteria is met THEN check to see if it meets a second set of criteria. If it meets the first and the second, only then should it output a match. I used the $madeMatch variable just to signify to myself if it were going through the conditional statements. In other words, I only want a match to be printed if and when $madeMatch ==1. Any thoughts??
for ($i = 0; $i < sizeof($eachSingle); $i++) {
$potentialMatch = explode(",", $eachSingle[$i]);
if ($singleInfo[1] != $potentialMatch[1] /*ensures gender isnt the same*/
&& $singleInfo[4] == $potentialMatch[4] /*ensures operating system is the same*/
&& $singleInfo[5] <= $potentialMatch[2] /* ensures single gets match above their min*/
&& $singleInfo[6] >= $potentialMatch[2] /*ensures single gets match under their max*/
&& similar_text($singleInfo[3], $potentialMatch[3]) != 0)/*ensures personality is comparable*/
/* this nested if would come in after all the criteria on behalf of the SINGLE was met...
,since it was it not checks to see if the single's age is b/w the min and max of the potential max-- if it is then the matches are listed */
/*{
if ($potentialMatch[5] >= $singleInfo[2] && $potentialMatch[6] <= $singleInfo[2])*/
{$madeMatch=0;
echo $madeMatch;
{if ($potentialMatch[5] >= $singleInfo[2] && $potentialMatch[6] >= $singleInfo[2])
{$madeMatch=1;
echo $madeMatch;
}}
?>
<div class="match">
<p><img src="user.jpg" alt="user"/><?= $potentialMatch[0] ?></p>
<ul>
<li><strong>Gender:</strong><?= $potentialMatch[1] ?></li>
<li><strong>Age:</strong><?= $potentialMatch[2] ?></li>
<li><strong>Type:</strong><?= $potentialMatch[3] ?></li>
<li><strong>OS:</strong><?= $potentialMatch[4] ?></li>
</ul>
</div>
Aucun commentaire:
Enregistrer un commentaire