Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

First post here and new member. I am new to programming and have taken the responsibility to create a website where students get their marks online. I need help creating a table where the number of rows depends on how many of the logged on users fields are not empty and has value in them

For example if say the user has 7 fields of which are empty and 4 has value, I want the table to have 4 rows

And is it possible to put the sql table headers into the rows of above dynamic table.

Thanks in advance any help is much appreciated and sorry for the messy spelling

EDIT:
Sorry for the undetailed post ok here is as much detail I can provide as possible

Database is MySql or I assume its called that I am using the MySql server from xampp

Next I am using PHP to create a website where once a student inserts their username and password they get their results back

For each year they have attempted (passed a/o failed ) they get a card of that years end marks back

At the moment I can get all subject names back from database in which table they are headers and have stored them in an array

However I am stuck at not knowing how to determine which subject (column header)is null or has value in it

Here is how I get the said headers back
PHP
{{
    $queryallsubname = $con->query("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'DatabaseName' AND TABLE_NAME = 'TableName'");

    while($rowallsubname = $queryallsubname->fetch_assoc()){
        $resultallsubname[] = $rowallsubname;
    }
    
    $columnArrallsubname = array_column($resultallsubname, 'COLUMN_NAME');
    $numoftotalcol = count($columnArrallsubname);
    for ($i=2; $i < $numoftotalcol; $i++) {
        echo $columnArrallsubname[$i];
    }
}}

I need a way to check which of the table columns above is empty/null so these not null headers will be the subject names of a year on the end card, as far as sources/guides go I am taking in everything I can find and anything I have tried so far fails

Thanks for the replies

What I have tried:

At the time of posting this question nothing, I was hoping for this to be my starting point
Posted
Updated 3-Mar-20 3:03am
v2
Comments
[no name] 1-Mar-20 21:43pm    
Doesn't sound like a "normal" database design. And not all "SQL data bases" are created equal. Consult the MySQL, Oracle, whatever "Start" guides / tutorials; because we don't know what you're using.
Maciej Los 2-Mar-20 5:13am    
What's your database model?
Jörgen Andersson 2-Mar-20 9:29am    
Sounds like you have caught the 'EAV disease' also known as 'One True Lookup syndrome'. We've all been there. Don't.

Or at least read this before going any further: https://www.red-gate.com/simple-talk/blogs/when-the-fever-is-over-and-ones-work-is-done/
W Balboos, GHB 2-Mar-20 11:00am    
Considering you are new to programming that is a rather ambitious project. I can't be sure about this but it seems either like homework, or worse, someone, somewhere will need to depend upon you design - possibly paying for it.

If it's homework, the struggle is where you learn.
If it's real work and someone is going to depend upon it (aside from you, yourself) then they are being cheated by the person who assigned this to you.

Again, I cannot be sure - but such posts lean in that direction
MCurse 8-Mar-20 14:54pm    
mark this as solved ih vae finnished the project thanks for the answers
and there is talk that it will get denied before review since it goes agianst some of the college rules
if anyone wants to know about the code for a semilar project hit me up

1 solution

sorry for the undetailed post ok here is as much detail i can provide as possible
database is mysql or i assume its called that iam using the mysql server from xampp
next iam using php to create a website where once a student inserts their username and password they get their results back
for each year they have attemped (passed a/o failed ) they get a card of that years end marks back
at the moment i can get all subect names back from database in which table they are headers andhave stored them in an array
however iam stuck at not knowing how to determine which subject (column header)is null or has value in it
here is how i get the said headers back {{
$queryallsubname = $con->query("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'DatabaseName' AND TABLE_NAME = 'TableName'");

while($rowallsubname = $queryallsubname->fetch_assoc()){
$resultallsubname[] = $rowallsubname;
}


$columnArrallsubname = array_column($resultallsubname, 'COLUMN_NAME');
$numoftotalcol = count($columnArrallsubname);
for ($i=2; $i < $numoftotalcol; $i++) {
echo $columnArrallsubname[$i];
}
}}
i need a way to check which of the table colomns above is empty/null so these not null headers will be
the subject names of a year on the end card, as fars sources/guides go iam taking in everything i can find and anything i have tried so far faills

thanks for the replies
 
Share this answer
 
Comments
Patrice T 2-Mar-20 10:53am    
Use Improve question to update your question.
So that everyone can pay attention to this information.
Maciej Los 13-Mar-20 7:09am    
This is not an answer. Please, delete it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900