Hello, I have a database, consisting of 8 tables. I am linking my php code with my database, now what i am trying to do is to join two columns of the two seprate tables and display them together in my php page. But whenever I excecute my page it does not provide any out. Its totally empty. Kindly help me out.

Here is my Code:

<!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=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>SlickRed | florida web design</title>
</head>

<body>
<?php
session_start();
$connection = mysql_connect('localhost','root','');
if(!$connection){
    die("Database Connection Failed". mysql_error());
    }
$select_db = mysql_select_db('hamdard_attendance');
if(!$select_db){
    die("Database Connection Failed" . mysql_error());
    }

if(isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];

$query_one = "SELECT * FROM users WHERE user_name = '".$username."' AND user_pass = '".$password."'";
$result = mysql_query($query_one) or die(mysql_error());
$count = mysql_num_rows($result);

if ($count == 1){
$_SESSION['username'] = $username;
}else{
echo "Invalid Login Credentials.";
}
}
if (isset($_SESSION['username'])){
$username = $_SESSION['username'];
}


?>
<div id="container">
        <div id="header">
            <h1 style="text-align:left">Quality Management<span class="off"> Cell</span></h1>

        </div>   

        <div id="menu">
            <ul>
                <li class="menuitem"><a href="#">Home</a></li>
                <li class="menuitem"><a href="#">Attendance</a></li>
                <li class="menuitem"><a href="#">Courses</a></li>
                <li class="menuitem"><a href="#">Settings</a></li>

            </ul>
            <a style="text-align:right" href="#">Logout</a>
        </div>





        </div>




        <div id="content">


        <div id="content_top"></div>
        <div id="content_main">
<?php echo "<h2> Welcome ".$username."</h2>"?>
<?php 
if(isset($_POST['stdnt_name']) && isset($_POST['course_name']) && isset($_POST['stdnt_rfid_tag']) && isset($_POST['student_id']) && isset($_POST['course_id'])){
$username = $_POST['stdnt_name'];
$password = $_POST['course_name'];
$username = $_POST['stdnt_rfid_tag'];
$password = $_POST['student_id'];
$username = $_POST['course_id'];

            $query_two = " SELECT s.stdnt_name, c.course_name FROM students s INNER JOIN student_courses sc ON s.stdnt_rfid_tag = sc.student_id INNER JOIN courses c ON sc.course_id = c.course_id";
    $result_attendance = mysql_query($query_two) or die(mysql_error());
    while($row = mysql_fetch_array($result_attendance)){
        echo $row[1]." ".$row[2]."<br/ >";
        }}
?>

            <p>&nbsp;</p>
            <p>&nbsp;</p>

        <div id="content_bottom"></div>

            <div id="footer"><h3><a href="http://www.bryantsmith.com">florida web design</a></h3></div>
      </div>
   </div>
</body>
</html>
Member Avatar for iamthwee

Take it one step at a time first see if you can connect to the db, then do a simple select all statement...

It could be anything.

my upper query is working, but the join query is not working, my db is connected for sure. i am facing the problem in this join query please help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.