[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

refer to images in other page

i am a php beginner and need to apply loops, arrays...
My task is:
i have one page category.php
the user selects from 4 categories of images he can see: travel, portrait, abstract, dance
when he clicks a radio button...he has to be taken to the next page catalog.php where in
each category he sees four images with the image description and the price. I do not know how to do that link.
my category.php looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

<meta name="author" content="Angelika Bertsch"/>
<meta name="description" content="angelika bertsch creative imagery photography"/>
<meta name="keywords" content="photography,black and white photography"/>
<meta name="last modified" content="april 19,2006"/>
<meta http-equiv="content-type"content="text/html;charset=ISO-8859-5"/>

<link href="abertsch.css" type="text/css" rel="stylesheet"/>


<div id="logo">
<p class="logo1">Angelika Bertsch </p>
<p class="logo2">       Creative Imagery</p>
<p class="logo3">              www.abertsch.com</p>

print date("D dS M,Y h:i a");
<form action = "category.php" method = "post">
<h1>I offer images within the following galleries</h1>
Please choose one of them:<br />

<input type = "radio" name = "category" value = "travel" checked/>travel<br />
<input type = "radio" name = "category" value = "portrait"/>portrait<br />
<input type = "radio" name = "category" value = "abstract"/>abstract<br />
<input type = "radio" name = "category" value = "dance"/>dance<br /><br />

<input type = "submit" text = "submit" value = "submit"/>
<input type = "reset" text = "reset" value = "reset"/><br /><br />

if (isset ($_POST['submit']))
choose a category
user input  categories = array("travel","music","abstract","dance")

if user choose pos1 show 3 travel images in catalog.php
if user choose pos2 show 3 music images
if user choose pos3 show 3 abstract images
if user choose pos4 show 3 dance images


1 Solution

Actually this shouldn't be to hard. You can use the switch-statement to test $_POST['category'] and output the correct images:

if(isset($_POST['category']) { ///if (isset ($_POST['submit']))
  switch($_POST['category']) {
     case 'travel';
        echo '<img src="travel1.jpg" />';
        echo '<img src="travel2.jpg" />';
        echo '<img src="travel3.jpg" />';
     case 'music';
        echo '<img src="music1.jpg" />';
        echo '<img src="music2.jpg" />';
        echo '<img src="music3.jpg" />';
     case 'abstract';
        echo '<img src="abstract1.jpg" />';
        echo '<img src="abstract2.jpg" />';
        echo '<img src="abstract3.jpg" />';
     case 'dance';
        echo '<img src="dance1.jpg" />';
        echo '<img src="dance2.jpg" />';
        echo '<img src="dance3.jpg" />';


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now