when i login my account in localhost and when I click the link to generate a pdf file it works perfectly with table and SQL data. but when I login another account the table doesn't exit.
This is one of my example of my codes:
$query = mysqli_query ($conn, "SELECT * FROM grade WHERE SEM = 1 AND YR = 1 AND STUDENT_NUMBER = '".$_SESSION["usersnum"]."' AND LAST_NAME = '".$_SESSION["lastname"]."' AND FIRST_NAME = '".$_SESSION["firstname"]."'");
if(mysqli_num_rows($query) > 0){
while($row = mysqli_fetch_array($query))
{
$html .='<table>
<tr>
echo "<td>'.$row["SUBJ_CODE"].'</td>"
echo "<td colspan = "3">'.$row["SUBJ_DESC"].'</td>"
echo "<td>'.$row["GRADE"].'</td>"
echo "<td>'.$row["UNIT"].'</td>"
</tr>
</table>';
Screenshot of table doesn't exist in another account
the Second image have table exist
I think the CSS style do not read when I login in another account in localhost.
$html = '<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
table{
border-collapse: collapse;
width: 100%;
font-size: 12px;
table-layout: fixed;
}
td, th{
border: 1px solid;
text-align: left;
}
.total{
text-align: right;
}
</style>
</head>
<body>
<table>
<tr>
echo "<th>Name: '.$_SESSION["lastname"].' '.$_SESSION["firstname"].' '.$_SESSION["middlename"].'</th>"
echo "<th>Course: '.$_SESSION["course"].' '.$_SESSION["cyear"].' '.$_SESSION["section"].'</th>"
echo "<th>Student number: '.$_SESSION["usersnum"].'</th>"
</tr>
</table>';
}}
the code above is the one do not read when I login into another which the CSS style are included.
<?php
session_start();
error_reporting(0);
if(isset($_SESSION["usersnum"])){
}else {
header("location: login.php");
exit();
}
This is also my codes included from above.
My Answer:
"SELECT * FROM table_name WHERE user_id = $user_id";
while ($row = mysqli_fetch_assoc($query)) {
// code to display table data
}
This code is fetching data from a table based on the user_id of the logged-in user. If the table is not displaying when logging in with another account, it could be due to the user_id not being passed correctly or the user not having access to the table data.
Make sure that the user_id is being passed correctly and that the user has the necessary permissions to access the table data. You may also want to check the SQL query to ensure it is retrieving the correct data for the logged-in user.
Rate this post
4 of 5 based on 8088 votesComments