Jump to content

Can you make an image post from input into a form instead of text?


christyk

Recommended Posts

I am very new to PHP, have been reading tutorials on line and I have figured out how to partially do what I am trying to do....

 

Im using a form so the visitor to the site can choose a selection on two drop down menus. Depending on the combination of choices they will get a different response in a frame below. Right now I have it so that text shows up in relation to their choices but what I want is for a specific image to show up depending upon their two selections.

 

I am just not sure even how to search for this question, can anyone give me a clue of where to look or what this would involve?

 

Here is a link to what I have created so far (not all the drop down combos are set up yet)

http://www.christykarpinski.com/simcam/form.php

 

Thanks!

Couple of ways come to mind - using Switch or using an array

 

rough psuedo code idea using Switch

 


Menu 1       Menu 2
A                 A
B                 B
C                 C

$display = menu1 . menu2

switch ($display){ 
case "AA": 
	echo "<IMG SRC='aa.jpg'>";
break; 
case "AB": 
	echo "<IMG SRC='ab.jpg'>";
break;
case "AC": 
	echo "<IMG SRC='ac.jpg'>";
break;
case "BA": 
	echo "<IMG SRC='ba.jpg'>";
break;
case "BB": 
	echo "<IMG SRC='bb.jpg'>";
break;
case "BC": 
	echo "<IMG SRC='bc.jpg'>";
break;
case "CA": 
	echo "<IMG SRC='ca.jpg'>";
break;
case "CB": 
	echo "<IMG SRC='cb.jpg'>";
break;
case "CC": 
	echo "<IMG SRC='cc.jpg'>";
break;
} 

code for the imageframe.php

 

<html>

<head></head>

<body>

 

<html>

 

<body>

 

<?php

// get form selection

$day = $_GET['day'];

// check value and select appropriate item

if ($aperture == 2 && $shutter == 2) {

    $special = 'f 2.8 at 1/2 second';

    }

elseif ($aperture == 4 && $shutter == 2) {

    $special = 'f 4 at 1/2 second';

    }

elseif ($aperture == 5 && $shutter == 2) {

    $special = 'f 5.6 at 1/2 second';

    }

else {

    $special = 'begining exposure image';

}

?>

 

<h2>Your exposure  is:</h2>

<?php echo $special; ?>

</body>

</html>

<html>
<head></head>
<body>

<html>

<body>


<h2>Your exposure  is:</h2>
<?php
// get form selection
$day = $_GET['day'];
// check value and select appropriate item
if ($aperture == 2 && $shutter == 2) {
    echo "<IMG SRC='22.png'>";
    }
elseif ($aperture == 4 && $shutter == 2) {
    echo "<IMG SRC='42.png'>";
    }
elseif ($aperture == 5 && $shutter == 2) {
    echo "<IMG SRC='52.png'>";
    }
else {
   echo "begining exposure image";
}
?>
</body>
</html> 

 

Or you can do as litebearer stated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.