Jump to content

retieve table data


dannyone

Recommended Posts

ok im a little stuck on this, i am trying to collect all of the course_id's, time_slots, RoomName and days from a table, for a specific logged in user. im using a sessions and storing the student_id in a variable $login.

 

i have 3 tables, Student, Course, Student_Course

 

Student:

Student_ID <-- collects student_ID from here and stores in $login

 

Course:

course_id, RoomName, Time, Day

 

Student_Course:

Student_ID, course_id

 

a student takes 3 courses 3 times a week, and a need to return all courses, times rooms and dates, can someone have a look an see where i am going wrong please

 

it'd be great if some1 could help  :) heres my code:

 

<?php

require_once('auth.php');

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>My Profile</title>

<link href="loginmodule.css" rel="stylesheet" type="text/css" />

</head>

<body>

<h1>My Profile </h1>

<a href="member-index.php">Home</a> | <a href="student_logout.php">Logout</a>

<p>This is another secure page. </p>

 

<?php

 

 

 

echo '<div class="details">';

echo '<div class="detailsleft">';

echo '<h6><em>Your Details:</em></h6>';

 

$result=mysql_query("SELECT * FROM Student,Course,Student_Course WHERE Student.Student_ID=Student_Course.Student_ID,Course.course_id=Student_Course.course_id AND Student.Student_ID='$login'");

$row=mysql_fetch_array($result);

 

echo '<p><b>Course id:</b> '.$row['course_id'].'</p>';

echo '<p><b>Time:</b> '.$row['Time_slot'].'</p>';

echo '<h6><em>Timetable:</em></h6>';

echo '<p><b>Room Name:</b> '.$row['RoomName'].'</p>';

echo '<p><b>First Name:</b> '.$row['FName'].'</p>';

echo '<p><b>Day:</b> '.$row['day'].'</p>';

echo '</div>';//details div left

echo '<div class="detailsright"><p>';

echo '</p>';

 

echo '</div>';//details div right

echo '</div>';//details div

echo '</div>';//main div

 

?>

 

 

</body>

</html>

 

 

 

thanks in advance

 

Danny

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/144815-retieve-table-data/
Share on other sites

$result=mysql_query("SELECT * FROM Student,Course,Student_Course WHERE Student.Student_ID=Student_Course.Student_ID,Course.course_id=Student_Course.course_id AND Student.Student_ID='$login'");

$row=mysql_fetch_array($result);

 

Select Star? Replace that star with the table name. Thats a start ;)

Link to comment
https://forums.phpfreaks.com/topic/144815-retieve-table-data/#findComment-760280
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.