Mason C.

asked • 10/13/22

comparing php array in while loop

I'm trying to get this while loop to compare the users selection in $brandSel which is assigned via a combobox

to an array value $phoneBrand which is assigned from reading out a text file. But it does not seem to be working.


$brandSel = $_POST["brand"];

//check if user has selected All or a specific brand display selections accordingly

if($brandSel == "All" OR $brandSel == $phoneBrand[$i]){

while($i < sizeof($phoneBrand)){

$i++;

echo "<tr><td></td><td>".$phoneBrand[$i]."</td><td>".$phoneModel[$i]."</td><td>".$phonePrice[$i]."</td></tr>";

}

}



2 Answers By Expert Tutors

By:

Rize S. answered • 03/23/23

Tutor
New to Wyzant

Master's in MISM, 25 yrs Exp: HTML Expert

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.