Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8574831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:33:46+00:00 2026-06-11T19:33:46+00:00

The purpose of the database I’m using a mysql database with an Apache server

  • 0

The purpose of the database

I’m using a mysql database with an Apache server to store homeschool information. I’m trying to track each assignment similar to a grade book where I can query by subject and month to track scores.

My database design

assignment is the main table and has: id(primary auto inc), student_id, subject_id, points_id, date, Notes_id, and type.

notes contains optional notes on the assignment and has id(primary auto inc), note, and date.

points has the score and total available for the assignment and contains id(primary auto inc), received, and total.

student is a list of students(my children) and contains id(primary auto inc), first_name, and last_name(yes I know this column is pointless since its my kids but I did it for practice).

subject is a list of current subjects and contains id(primary auto inc), name, description. My logic was I can add more subjects pragmatically as needed each year.

type is contains the types of assignments and contains id(primary auto inc), name, description.

Now how do I join to print it out?

I need to join assignment, student, subject, points, notes into one table that I can iterate through with a while loop to echo out recent activity (data entry) into an html table.

I’ve tried many versions similar to:

$result = mysql_query("SELECT * FROM assignment, student, subject, points, notes
                            WHERE assignment.student_id = student.id 
                            AND assignment.subject_id = subject.id 
                            AND assignment.points_id = points.id 
                            ");

Doing so has yielded only empty queries. Can someone nudge me in the right direction? The end result I’m looking for is a combined table that fills in the stored _id’s in assignment with the values I want to display such as: 9/12/2012 Jane Doe Math Quiz 25/28 in an html table.

Additional info if needed… PHP function storing the data

function submit_entry($con){
    $student = $_POST['student'];
    $subject = $_POST['subject'];
    $type = $_POST['type'];
    $notes = mysql_real_escape_string($_POST['notes'],$con);
    $received = mysql_real_escape_string($_POST['received'],$con);
    $total = mysql_real_escape_string($_POST['total'],$con);
    
    //Retreive student data
    $token = strtok($student, " ");
    $student_firstname = $token;
    $token = strtok(" ");
    $student_lastname = $token;
    $result = mysql_query("SELECT * FROM student WHERE first_name='$student_firstname'");
    $row = mysql_fetch_array($result);
    $student_id = $row['id'];
    
    //Retrieve subject data
    $result = mysql_query("SELECT * FROM subject WHERE name='$subject'");
    $row = mysql_fetch_array($result);
    $subject_id = $row['id'];
    
    //Retrieve type
    $result = mysql_query("SELECT * FROM type WHERE name='$type'");
    $row = mysql_fetch_array($result);
    $type_id = $row['id'];
    
    //obtain last inserted ID (assignment)
    if(!mysql_query("INSERT INTO points ( received, total)
    VALUES ('$received', '$total')"))
    {
        die('Error:  ' . mysql_error() . ' in points INSERT!');
    }
    $points_id = mysql_insert_id();
        
    if(!mysql_query("INSERT INTO assignment (student_id, subject_id, type, date, points_id)
    VALUES ('$student_id', '$subject_id', '$type_id', NOW(), '$points_id')"))
    {
      die('Error: ' . mysql_error() . ' in assignment INSERT!');
    }
    

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:33:47+00:00Added an answer on June 11, 2026 at 7:33 pm

    I’ve simi gone with Remm’s suggestion. I’m polling for the values in each table (student, subject, and type) and storing them in an associative array.

    function recent_activity($count){
    
    $subject_list;
    $student_list;
    $assignment_type;
    $alt_table = false;
    
    //build arrays with keys for echo
    $result = mysql_query("SELECT * FROM subject");
    while($row = mysql_fetch_array($result))
    {
        $subject_list[$row['id']] = $row['name'];
    }
    
    $result = mysql_query("SELECT * FROM student");
    while($row = mysql_fetch_array($result))
    {
        $student_list[$row['id']] = $row['first_name'] . " " . $row['last_name'];
    }
    
    $result = mysql_query("SELECT * FROM assignment ORDER BY date DESC LIMIT $count");
    $entry_date = null;
    
    while($row = mysql_fetch_array($result))
    {
        if($entry_date != $row['date'])
        {
            if($entry_date == null)
            {
                $entry_date = $row['date'];
                $entry_date_array = date("F j Y", strtotime($row['date']));
                $token = strtok($entry_date_array, " ");
                $token = strtok(" ");
                create_date($token, substr($entry_date_array, 0, 3));
                echo "<table class=\"student-table\">";
                $alt_table = false;
            }
            else
            {
                echo "</table>";
                echo "<div class=\"clear_float\"></div>";
                $entry_date = $row['date'];
                $entry_date_array = date("F j Y", strtotime($row['date']));
                $token = strtok($entry_date_array, " ");
                $token = strtok(" ");
                create_date($token, substr($entry_date_array, 0, 3));
                echo "<table class=\"student-table\">";
                $alt_table = false;
            }
        }
    
        if($alt_table == true)
        {
            echo "<tr class=\"alt\">";
            $alt_table = false;
        }
        else
        {
            echo "<tr>";
            $alt_table = true;
        }
    
        echo "<td>" . "<a href=\"" . $student_list[$row['student_id']] . "\">" . $student_list[$row['student_id']] . "</a>" . "</td>";
        echo "<td>" . $subject_list[$row['subject_id']] . "</td>";
        $row_id = $row['id'];
        $points_result = mysql_query("SELECT * FROM points WHERE id = '$row_id' ");
        $points_row = mysql_fetch_array($points_result);
        echo "<td>" . $points_row['received'] . " / " . $points_row['total'] . "</td>";
        echo "</tr>";
    }
    
    echo "</table>";
    echo "<div class=\"clear_float\"></div>";
    }
    
    function create_date($day, $month){
    echo "<div class=\"date\">" . "<p>" . $day ."<span>" . $month . "</span>" . "</div>";
    }
    ?>
    

    It’s still a touch buggy. I want the tables to be separated by dates with a css created date block inserted infront of each one. Currently I am getting inaccurately created dates which is the result of an unforeseen problem with the statement

    if($entry_date != $row['date'])
    

    I can see how this project could be misconstrued as homework from the thoroughness of my details. Being a professional medical machinist programmer/operator has made me appreciate the importance of clearly communicating information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a database as a kind of cache - the purpose is to
I am trying to get metadata from an sqlite database. The main purpose for
For the purpose of building a database system I am using a simple builder
I want to store and retrieve images to/from database using java beans, which data
I have two similar database with the same schema.But one is for printing purpose.
I am using HSQL in memory database for test purpose of my application and
Im Trying to use CouchDb as a NoSQL database and my main purpose is
The purpose of this code is to pull upgrade.zip from a central server, extract
For audit logging purpose I override SaveChanges() method in EF 4.1 Database-First approach .
How can I manually introduce an integrity error into my database for the purpose

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.