I want to display images based on what user checked from number of checkboxs. I'm trying this code, but it not working

<!Doctype html>
<html><body>
<form method="post" action="" id="myForm">
    <div class="opt-first">
    <h1><b>Subject</b></h1>
        <input type="checkbox" value="Account/Finance" name="subject[]" /> Account/Finance<br />
        <input type="checkbox" value="Marketing" name="subject[]" /> Marketing<br />
        <input type="checkbox" value="" name="subject[]" /> Other
    </div>

    <div class="opt">
    <h1><b>Type</b></h1>
        <input type="checkbox" value="Exam" name="Type[]" /> Exam<br />
        <input type="checkbox" value="Project" name="Type[]" /> Project<br />
        <input type="checkbox" value="Assignment" name="Type[]" /> Assignment
    </div>

    <div >
    <h1><b>Tasks</b></h1>
        <input type="checkbox" value="Report" name="Task[]" /> Report<br />
        <input type="checkbox" value="Presentation" name="Task[]" /> Presentation<br />
        <input type="checkbox" value="Assay" name="Task[]" /> Assay<br />
        <input type="checkbox" value="Case study" name="Task[]" /> Case study<br />
        <input type="checkbox" value="Teaching" name="Task[]" /> Teaching<br/>
        <input type="checkbox" value="Website Design" name="Task[]" /> Website Design<br/>
        <input type="checkbox" value="Short Answer" name="Task[]" /> Short Answer

    </div>
    <div><h1><b>Group/Individual </b></h1>
            <input type="checkbox" value="Yes" name="member[]" /> Group Work<br />
        <input type="checkbox" value="" name="member[]" /> Individual <br />
</div>    
    <input type="submit" value="Show" class="submit" />
</form>

<?php

if (isset($_POST['Subject']) && isset($_POST['Type']) && isset($_POST['Task'])&& isset($_POST['member']))
{
    $con=mysqli_connect("localhost","FYP","123","FYP");
echo "<div>";

    foreach ($_POST['Subject'] as $Subject)
    {
        foreach ($_POST['Type'] as $Type)
        {
            foreach ($_POST['Task'] as $Task)
            {
                foreach ($_POST['member'] as $member)
                {
                $sql= mysqli_query($con, "SELECT R_Name FROM rubric_sample WHERE Subject='$Subject' AND Type='$Type' AND Task='$Task' AND Group='$member'");
                while($row = mysqli_fetch_array($sql)){
                    echo "<img src='/Rubrics/".$row['R_Name']." alt='Rubrics Sample ' style='width:128px;height:128px'>";
                }
                }
            }
        }
    }

  echo "</div>";
}

?>



</body></html>

Could you please help me to correct my code or suggest me a better way to do it

Member Avatar for diafol

That's all wrong.

Firstly how are your images stored? Are they categorized or do they have "tags"?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.