string matching in php, sometimes it works, sometimes not, what am I missing?

fubergen

New Member
So I have a search form, and when the search result page loads, there are some jump menu's at the top to allow a user to narrow down the results.The jump menu's show the selected search criteria from the posted form.However, in the 'Ports' jump menu, if you choose Bristol or Edinburgh, when you land on the results page, the ports menu doesn't show them as selected. It does for all the others...Here's my search select code from the cruise search box\[code\]<select name="port" id="port"><option selected value="http://stackoverflow.com/questions/10548922/%">All Ports...</option><option value="http://stackoverflow.com/questions/10548922/Bristol Avonmouth">Bristol Avonmouth</option><option value="http://stackoverflow.com/questions/10548922/Edinburgh Leith">Edinburgh Leith</option><option value="http://stackoverflow.com/questions/10548922/Glasgow Greenock">Greenock</option><option value="http://stackoverflow.com/questions/10548922/Hull">Hull</option><option value="http://stackoverflow.com/questions/10548922/Liverpool">Liverpool</option><option value="http://stackoverflow.com/questions/10548922/London, Tilbury">London Tilbury</option><option value="http://stackoverflow.com/questions/10548922/Newcastle">Newcastle</option></select>\[/code\]and here's the jump menu code on the results page\[code\]<div id="cac"> <h3>Sailing from...</h3> <p>&nbsp;</p> <p> <select name="jumpMenu3" id="jumpMenu3" onchange="MM_jumpMenu('parent',this,0)"> <option value="">Select a port</option> <?php $ports = array(); mysql_data_seek($cruises, 0); while ($row_cruises = mysql_fetch_assoc($cruises)) { if (!in_array($row_cruises['fromport'], $ports)) { $ports[] = $row_cruises['fromport']; ?> <option value="http://stackoverflow.com/questions/10548922/index.php?subj=2&destination=<?php echo urlencode($row_cruises['destination']);?>&departs=<?php echo date('Ym',strtotime($row_cruises['departs']));?>&port=<?php echo urlencode($row_cruises['fromport']);?>"<?php if ($_GET['port'] == $row_cruises['fromport'] OR $_POST['port'] == $row_cruises['fromport']) {echo "selected=\"selected\"";}?>><?php echo $row_cruises['fromport']; ?></option> <?php } ; } if(mysql_num_rows($cruises) > 0) { mysql_data_seek($cruises, 0); $row_cruises = mysql_fetch_assoc($cruises); } ?> </select>\[/code\]I've checked the ports themselves in the database for spelling, case, spacing... all good.Maybe I need a like or wildcard comparison operator ? doh doh dohFixed it - the port look up isn't against the ports table, it's against what written for the departure port in the cruises table, and there are some cruises that are entered wrong...Rich :)
 
Back
Top