Page 1 of 1

help with linking tables etc..

Posted: Thu Oct 21, 2010 9:18 am
by boneh
hi,
I have a problem with something but I can't find the code of it,
First the people have to login, then they have to choose between wich categorie they are, example: kids/older people/..
and they can select a lesson they want to follow, after clicking on the lesson they have to choose the date, and when they press on the button,
my database should automaticly link the lesson they want to follow, on the persons name etc... So I can see wich person, wich lesson wants to follow.
In my database I make 3 tables: lesson/user/user_lesson. So the user should be auto linked with lesson. Someone can help me with showing the code?
in user I got everything like name etc, in lesson I got the lessons, but now I should get them in 1 table. this is an example of a lesson code:

Code: Select all

<html>
<head>
<title>Memory les</title>
</head>
<body>
<font face="Arial" size="7">Memory</font><br>
<p>&nbsp;</p>
<p><font face="Arial"><img src="images/memory.png" align="right">Memory is een gezelschapsspel dat een beroep doet op het kortetermijngeheugen van de spelers. Het spel is door William Hurter ontwikkeld en verscheen voor het eerst in 1959 bij de firma Ravensburger. Dit spel is met meer dan 50 miljoen verkochte exemplaren in 70 landen het grote succesnummer van deze firma geworden.</font></p>
Tijdsduur: 90 minuten</br>
kostprijs: 5 €</br>
<form>
 Datum:
 <select>
 <?php
 $db = mysql_connect("localhost", "root")
 or die("Kan geen verbinding maken");
 mysql_select_db("inlog",$db);
 $sql = "SELECT * FROM lessen WHERE les = 'Memory_kinderen'";
 $resultaat = mysql_query($sql);
 while ($rij = mysql_fetch_array($resultaat)) {
 echo "<option value =\"";
 echo $rij["lesID"]."\">";
 echo $rij["datum"]."</option>\n";
 }
 ?>
 </select> 
</br>
<input type="button" value="Schrijf in" onclick="submitOption()" />
</form>
  <script>
  function submitOption() {
var mySelect = document.getElementById('my_select');
location = mySelect.value;
}
</script>
</body>
</html>

Re: help with linking tables etc..

Posted: Fri Oct 22, 2010 5:33 am
by rahulzatakia
Hi, I think you just need to use "join" in sql query where you are fetching user details from the database. I think user_lesson table have the mapping of user and the lesson they have selected so you just need to join the user and user_lesson tables. And if you can provide me more details i can work out for you.