Jump to content

Trying to make simple search with image result in php and html,


ricardogarcia

Recommended Posts

Okay here is what I'm trying to do...--------------------------------------------------primary function of what 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...---------------------------------------------------------------------PHP--Form-------------------------------------------------------------------------------<?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);// need to add whatever validation/sanitation of zip code value here $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($zipcode, $loc1)) {echo $image1;}else if(in_array($zipcode, $loc2)) {echo $image2;}else {echo $image3;$form['#zipcode'] = FALSE;exit();}?>---------------------------------------------------------------------PHP--Form--End----------------------------------------------------------------------------------------------------------------------------------------------HTML--Form-------------------------------------------------------------------------------<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'><div id="actions"><input type='submit' value='Search' onclick="submitclick(); return false;" id='submitbutton' class='zipcode_button'><td><id="zipcodeError" value='' class="zipcode_button"/></td></div></form></html>---------------------------------------------------------------------HTML--Form--End----------------------------------------------------------------------------

Edited by ricardogarcia
Link to comment
Share on other sites

So where is the problem?

 

I see you have a few variables that are not being used anywhere, namely $width, $height and $form.

 

PHP scripts only run as the page loads, if you want to run them again you have to load the page again.

 

 

This isn't valid HTML

<td><id="zipcodeError" value='' class="zipcode_button"/></td>

A <td> element shouldn't be here, and the other element <id="zipcodeError"> does not have a name.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

The part of the code that i'm having issues is that if;

 

i load the page in browser, it displays some of the php code and image on top of template,

(if(in_array($zipcode, $loc1)) { echo $image1; $width = 100; $height = 662; } else if(in_array($zipcode, $loc2)) { echo $image2; $width = 100; $height = 662; } else { echo $image3; $width = 100; $height = 662; $form['#zipcode'] = FALSE; exit(); } ?>) i'm not to sure if the code is correct but,

...i'm really just trying to shape the code just to do the following described,

 

" 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.. "

 

thanks very much

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...