I am building a recommendation system for events ( for a charity so a charity can hold so many events etc) and in the end of this I want to display for each user a different set of events that are recommended to them based on their interests. So when a user logs in they will answer a questionnaire on their interests (3 interests to be exact for now). These interests are stored in a database as interests table. I am unsure how to link the user table (has all the users info like password name etc) with the interests table to show what interests each user has. Next then I want to show what events matches with the users interests is it possible to join three tables so that the end result will be the userID along with their interests and the corresponding events that match these interests.
User
userID
Events
eventID
Intrests
InterestID
UserIntrests
UserID
IntrestID
EventIntrests
eventID
IntrestID
I have encountered a problem when it comes to inserting data into the tables i am trying to insert the 3 chosen interests into the user interest table however it must go under the users id that is currently signed in? Any help would be greatly appreciated.
if(isset($_POST['save']))
{
$sql = "INSERT INTO UserInterests (id, InterestId)
VALUES ('".$_SESSION["id"]."','".$_POST["InterestDescription"]."')";
$result5 = mysqli_query($connection,$sql);
}
?>
<form action="questionnaire.php" method="save">
<label id="first"> Interest 1</label><br>
<input type='hidden' name='id' value=$_SESSION["id"]>
<?php
$select= '<select name="select">';
while($row = mysqli_fetch_array($result))
{
$select.="<option value='".$row['InterestDescription']."'>".$row['InterestDescription']."</option>";
}
$select.='</select>';
echo'<br></br>';
echo $select;
?>
<br><br>
<label id="second"> Interest 2</label><br>
<?php
$select2= '<select name="select2">';
while($row2 = mysqli_fetch_array($result2))
{
$select2.="<option value='".$row2['InterestDescription']."'>".$row2['InterestDescription']."</option>";
}
$select2.='</select>';
echo'<br></br>';
echo $select2;
?>
<br><br>
<label id="third"> Interest 3</label><br>
<?php
$select3= '<select name="select3">';
while($row3 = mysqli_fetch_array($result3))
{
$select3.="<option value='".$row3['InterestDescription']."'>".$row3['InterestDescription']."</option>";
}
$select3.='</select>';
echo'<br></br>';
echo $select3;
?>
<button type="submit" name="save">save</button>
</form>