0

I have two tables "setTearmlyExam.php" and "setTopics.php", what i want to do is this: in the "setTearmlyExam.php" i have a form with two select options, a radio button and a start button. each select option has an option from the database.

what am trying to do here is: when the start button is cliked, its will redirect to the "setTopics.php" and there display all the topics and question using the selected information on the "setTearmlyExam.php". I have two table where am selecting the data that will be displayed in the "setTopics.php"

The olevelguestion: enter image description here

Topics: enter image description here

"setTearmlyExam.php"

<form action="setTopics.php " method="POST" class="col s12" center>
    <!-- setTopics.php -->
    <div>
        <label>Select Term</label>
        <select name="terms" class="browser-default" required>
            <option value="" disabled selected>Select Term</option>
<?php
// Selecting terms from database
$select_terms = $db->query("SELECT * FROM term");
if (!$select_terms) {
    die('QUERY FAILED' .mysqli_error($db));
}
// Ends
// Using while loop tp fatch and loop term titles
while ($row = $select_terms->fetch_assoc()) {
    $termId = $row['termId'];
    $terms = $row['terms'];

    echo "<option value='{$termId}'>{$terms}</option>";
}
?>
        </select>
        <label>Select Subject</label>
        <select name="subjects" class="browser-default" required>
            <option value="" disabled selected>Select Subject</option>
<?php                                      
// Selecting subjects from database......
$Select_subjects = $db->query("SELECT * 
                                FROM subjects 
                                ORDER BY subj ASC");
if (!$Select_subjects) {
    die("QUERY FAILED" . mysqli_error($db));
}
// Ends..
// Using while loop to fetch the subjects title
while ($rw = $Select_subjects->fetch_assoc()) {
    $subjId = $rw['subjId'];
    $subj = $rw['subj'];
    echo "<option value='{$subjId}'>{$subj}</option>";
}
?>
        </select>
    </div>
    <div class="ST">
        <div class="col 6">
            <label>
            <input class="with-gap" name="Examtype" value="O" type="radio" required/>
            <span>Objective</span>
            </label>
        </div>

        <div class="col 12">
            <label>
                <input class="with-gap" name="Examtype" value="T" type="radio" />
                    <span>Theory</span>
            </label>
        </div>
    </div>
</div>
</div>
<div class="card-action centerTxt">
    <button class="btn waves-effect waves-light " type="submit" name="start">Start
        <i class="material-icons right">send</i>
    </button>
</div>
</div>
</form>

"setTopics.php"

<form action="">
    <div class="card-content black-text">
        <span class="card-title centerTxt">
            <h4>Subject Title</h4>
        </span>
    <div>
    <!-- Dropdown Trigger -->
    <label for="">
        <h6 class="" style="font-size: 15px; color:black;">CLICK ON EACH TOPIC TO SELECT QUESTIONS. <span style="color:red; font-size: 13px;">Don't Select more than 50 Questions.</span></h6>
<?php
    $terms = 'terms';
    $subjects = 'subjects';
    //  $Examtype = $_GET['Examtype'];

    if ($Examtype = 'O') {
        $topics = $db->query('SELECT * FROM topics WHERE  ');
    }
?>
        <h5 class='dropdown-trigger ' style="color:#149fd5;" data-target='dropdown1'>Topics Here</h5>
    </label>
    <!-- Dropdown Structure -->
        <ul id='dropdown1' class='dropdown-content'>
            <p>
                <label>
                    <input type="checkbox" value="" />
                    <span>Yellow</span>
                </label>
            </p>
        </ul>
    </div>
</div>
<div class="card-action centerTxt">
    <button class="btn waves-effect waves-light " type="submit" name="start">Next
        <i class="material-icons right">send</i>
    </button>
</div>
</form>
15
  • 1
    ok. And specifically what problem are you having? Don't just dump a big piece of code on us and expect us to figure it out...explain your exact issue. Please see also How to Ask for more guidance. Thanks.
    – ADyson
    Commented Sep 15, 2021 at 11:49
  • the problem am having is this: when it redirect to the setTopics.php page i found it hard to select the two informtion i need, tho have used join but i'm confused on how do go about it Commented Sep 15, 2021 at 12:05
  • Ok. So, which information from the setTearmlyExam form is it supposed to be using in order to select the correct rows from Topics? Just the examType? And/or the subjects? Or what? It's not clear what your criteria are. Please edit the question with a more specific description of the requirements.
    – ADyson
    Commented Sep 15, 2021 at 12:11
  • the subjects and examtype Commented Sep 15, 2021 at 12:13
  • And which field in the database does "examType" map to? I don't see anything with that name, in your pictures.
    – ADyson
    Commented Sep 15, 2021 at 12:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.