phphtmlbenchmarkingselectedconstruction

HTML Selected Value If Statement PHP


I'm planning on making a website that has a function like this: http://www.hwcompare.com/category/gpu/

And I can't get the code sorted out to display a picture, some text and some benchmarks I want based on the value the user has selected.

HTML code:

<html>
<head>
    <title> Compare Master - The Master at System Comparison! </title>
</head>
<body>
Select a GPU you want to compare: <br>
<form action="compare.php" method="GET">
<select name="lelo" id="lelo">
 <optgroup label="Radeon HD Series">
  <option value="Radeon 3470">Radeon HD 3470</option>
  <option value="Radeon 3650">Radeon HD 3650</option>
 </optgroup>
 <optgroup label="Radeon R7 Series">
  <option value="R7 240">Radeon R7 240</option>
  <option value="R7 250">Radeon R7 250</option>
 </optgroup>
</select>
<br><input type="submit" name="submit" value="Submit your selections" />
</form>
</body>

and my PHP code:

<?php
    $gpu1 = $_GET['lelo'];
echo $gpu1;
?>

And I want my PHP to work like.. example: if (option value = 'R7 240') { display R7 240 image + R7 240 specifications }


Solution

  • <?php
    $gpu1 = $_GET['lelo'];
    if($gpu1=='R7 240'){
     echo '<img src='your source '>'
     }
    ?>
    

    also for dynamic source get your img via php then only change the source of img as you want