mysql - SQL results won't find and match each other in Foreach (PHP) -
i've been having problem matching sql results database. know they're there, because i've manually set them in. want matching results not display on page , non-matching results do.
the main problem i'm using foreach seek , loop through , match them php/sql not find , match them? create more understandable, here's example: (this part of it)
foreach ($db->query($sql) $row) { foreach ($db->query($completedvotesearch) $done) { if ($done['pollid'] == $row['polllid']) { echo "we have match!"; } if ($done['pollid'] != $row['polllid']) { echo "<br/>"; echo $done['pollid'] . ", "; echo $row['pollid'] . ", "; echo "<br/>"; $pollid = $row['pollid']; $title = $row['title']; $type = $row['type']; if ($type == "s") { $type = "radio"; } else { $type = "checkbox"; } $option1 = $row['option1']; $option2 = $row['option2']; $option3 = $row['option3']; $option4 = $row['option4']; $option5 = $row['option5']; $option6 = $row['option6']; $option1vote = $row['option1vote']; $option2vote = $row['option2vote']; $option3vote = $row['option3vote']; $option4vote = $row['option4vote']; $option5vote = $row['option5vote']; $option6vote = $row['option6vote']; $option1votecolumn = "option1vote"; $option2votecolumn = "option2vote"; $option3votecolumn = "option3vote"; $option4votecolumn = "option4vote"; $option5votecolumn = "option5vote"; $option6votecolumn = "option6vote"; } }
the problem "we have match!" not beingness echoed amount of times in page, though there 2 matches in database (76 , 26).
i know it's picking them both because i've done test echoing both of arrays out. , it's saying "76, 76," , "26, 26," in actual webpage.
any help fixing issue im having appreciated
are sure mean
if ($done['pollid'] == $row['polllid']) <-- 3 l's?
and not
if ($done['pollid'] == $row['pollid'])
since you're, later in code, using
echo $row['pollid']
php mysql
No comments:
Post a Comment