I'd like to pass an id value of a PHP generated button from theory.php
file to theory1.php
file.
Here's the code:
//theory.php file
require('components/db.php');
$query = "SELECT * FROM `courses`";
$result = mysqli_query($connect, $query) or die("Error:" . mysqli_error($connect));;
$numrows = mysqli_num_rows($result);
for ($i = 0; $i < $numrows; $i++) {
$query = "SELECT * FROM `courses` WHERE courseID = '$i'";
$result = mysqli_query($connect, $query) or die("Error:" . mysqli_error($connect));;
$rowQuery = mysqli_fetch_assoc($result);
$_SESSION['course_ID'] = $i;
echo '
<div class="card">
<img class = "cardImage" src="';
echo $rowQuery['imageLink'];
echo '" alt="Course 1">
<h3>';
echo $rowQuery['courseName'];
echo '</h3>
<p>';
echo $rowQuery['courseTextOne'];
echo '</p>
<a href="theory1.php?course_ID=$i" class="button">Proceed</a>
</div>'; //a - is a button which needs to have an ID to pass to theory1.php
}
The code generates cards with buttons. I want each button to store a respective ID from the course from MySQL database. That ID needs to be passed to another page depending on which button (card) is clicked, so it can retrieve the right data from the database in the future.