Result image to appear under search box using php and html
Posted: Fri Jan 02, 2015 10:14 am
**Question** | **This is really all i'm trying to do..**
-------------------------------------------------------------------------------------------
simply....
if the user picks a zipcode from $loc1 then image $image1(nextday) will show...
if user pick a zipcode from $loc2 than $image2(2nd-Day)will hopefully appear under the search box..
i hope that no page "redirect" is necessary... since images are displayed under search box area...
-------------------------------------------------------------------------------------------
**Problem** | **So far here's what happens..**
-------------------------------------------------------------------------------------------
and....
ok, one issue is; when test the form in the internet browser the images are displayed right of way before the submit button has been clicked, i'm not sure if it's a problem with using the "in_array"
also, any special way to code php with html too: make a image appear directly under the search box?
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
simply....
if the user picks a zipcode from $loc1 then image $image1(nextday) will show...
if user pick a zipcode from $loc2 than $image2(2nd-Day)will hopefully appear under the search box..
i hope that no page "redirect" is necessary... since images are displayed under search box area...
-------------------------------------------------------------------------------------------
**Problem** | **So far here's what happens..**
-------------------------------------------------------------------------------------------
and....
ok, one issue is; when test the form in the internet browser the images are displayed right of way before the submit button has been clicked, i'm not sure if it's a problem with using the "in_array"
also, any special way to code php with html too: make a image appear directly under the search box?
-------------------------------------------------------------------------------------------
Code: Select all
<?php
$zipcode = $_POST['zipcode'];
$loc1 = array (80013,80015,80126,80127,80128,80129,80130,80134,80135,80138,80160,80161,80162,80163,80165,80166,804 33,80453,80465,80470);
$loc2 = array (80023,80025,80136,80137,80138,80139,80140,80144,80145,80148,80140,80141,80142,80143,80145,80146,804 43,80443,80445,80440);
$image1 = '<img src="Section-Images/Section-Edits/1st--Day-img.png" alt="1st--Day.png/>';
$image2 = '<img src="Section-Images/Section-Edits/2nd--Day-img.png" alt="2nd--Day.png" />';
$image3 = '<img src="Section-Images/Section-Edits/2-3--Day.png" alt="2-3--Day.png" />';
if (in_array($zip, $loc1)) {
echo "<div class='banner'><img src='Section-Images/Section-Edits/Next--Day-img.png' /></div>
Count: $i = $displayitem[$i] ";
}
else if (in_array($zip, $loc2)) {
echo "<div class='banner'><img src='Section-Images/Section-Edits/2nd--Day-img.png' /></div>
Count: $i = $displayitem[$i] ";
}
else {
echo "<div class='banner'><img src='Section-Images/Section-Edits/2-3--Day.png' /></div>
Count: $i = $displayitem[$i] ";
}
exit();
?>
**HTML form:**
<html>
<div class="panel">
<div class="panel-content">
<form id="zipcode" action="<?php echo $_SERVER['PHP_SELF']; ?>" method='POST'>
<input type='text' size="6" maxlength="5" id='searchbar' class='searchbar2'name='zipcode'>
<input type='submit' value='Search' onclick="submitclick(); return false;" id='submitbutton'
class='zipcode_button'>
</div>
</form>
</html>