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

  • SEARCH
  • Home
  • 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 3675696
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:00:30+00:00 2026-05-19T03:00:30+00:00

I have a members only website in which the logged in users fill in

  • 0

I have a members only website in which the logged in users fill in an entry form which goes to a MySQL table called ‘ltd_sales_list’ with the following columns:

ltd_item_id | ltd_user_id |
ltd_invoice_no | ltd_entry_amount |
ltd_entry_date

For each new entry they input, a new id/primary key is generated (‘ltd_item_id’) for each row, while their SESSION log in id is recorded in ‘ltd_user_id’ while the ‘ltd_entry_date’ is a timestamp. The entry form page works fine but viewing the entry data is where I am having the issue.

I have put together the code below called view-list.php but this calls up every user’s entry list. What I am trying to do is show the logged in user’s entry list only.

I think the answer lies within the queries somewhere and have tried some WHERE statements with ltd_user_id = $_SESSION[‘ltd_user_id’] and similar but for no success.

If anyone could help or could point me to some links that would be greatly appreciated!

<?php 

require_once ('./includes/config.inc.php');

$page_title = 'Page Title';
include ('./includes/header.html');

if (!isset($_SESSION['ltd_user_id'])) {

   $url = 'http://' . $_SERVER['HTTP_HOST']
    . dirname($_SERVER['PHP_SELF']);

   if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
        $url = substr ($url, 0, -1); 
   }

   $url .= '/login.php'; 
ob_end_clean(); 
header("Location: $url"); 
exit(); 
}
?>

<div id="">HTML Content HERE</div>

<?php

echo '<h1>My Entry Log</h1>';

require_once ('/server/database_connection.php'); // Connect to the db.

$display = 10;

if (isset($_GET['np'])) { 
    $num_pages = $_GET['np'];
} else { 

    $query = "SELECT COUNT(*) FROM ltd_sales_list ORDER BY ltd_entry_date DESC";   
    $result = @mysql_query ($query);
    $row = mysql_fetch_array ($result, MYSQL_NUM);
    $num_records = $row[0];

    if ($num_records > $display) { 
       $num_pages = ceil ($num_records/$display);
    } else {
       $num_pages = 1;
    }
} 

if (isset($_GET['s'])) {
    $start = $_GET['s'];
} else {
    $start = 0;
}

$link1 = "{$_SERVER['PHP_SELF']}?sort=lna";
$link2 = "{$_SERVER['PHP_SELF']}?sort=fna";
$link3 = "{$_SERVER['PHP_SELF']}?sort=dra";

if (isset($_GET['sort'])) {

    switch ($_GET['sort']) {
       case 'lna':
          $order_by = 'ltd_invoice_no ASC';
          $link1 = "{$_SERVER['PHP_SELF']}?sort=lnd";
          break;
       case 'lnd':
          $order_by = 'ltd_invoice_no DESC';
          $link1 = "{$_SERVER['PHP_SELF']}?sort=lna";
          break;
       case 'fna':
          $order_by = 'ltd_entry_amount ASC';
          $link2 = "{$_SERVER['PHP_SELF']}?sort=fnd";
          break;
       case 'fnd':
          $order_by = 'ltd_entry_amount DESC';
          $link2 = "{$_SERVER['PHP_SELF']}?sort=fna";
          break;
       case 'dra':
          $order_by = 'ltd_entry_date ASC';
          $link3 = "{$_SERVER['PHP_SELF']}?sort=drd";
          break;
       case 'drd':
          $order_by = 'ltd_entry_date DESC';
          $link3 = "{$_SERVER['PHP_SELF']}?sort=dra";
          break;   
       default:
          $order_by = 'ltd_entry_date DESC';
          break;
    }

    $sort = $_GET['sort'];

} else { 
    $order_by = 'ltd_entry_date DESC';
    $sort = 'dra';
}

$query = "SELECT ltd_invoice_no, ltd_entry_amount,  
    DATE_FORMAT(ltd_entry_date, '%M %d, %Y') AS dr, ltd_user_id FROM ltd_sales_list ORDER BY
    $order_by LIMIT $start, $display";
$result = @mysql_query ($query); 

echo '<table width="520" cellspacing="1" cellpadding="11">
<tr>
    <td align="left"><b><a href="' . $link1 . '">Invoice Number</a></b></td>
    <td align="left"><b><a href="' . $link2 . '">Invoice Amount</a></b></td>
 <td align="left"><b><a href="' . $link3 . '">Date Entered</a></b></td>
</tr>
';

$bg = '#eeeeee'; 
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $bg = ($bg=='#eaeced' ? '#ffffff' : '#eaeced');  
    echo '<tr bgcolor="' . $bg . '">
       <td align="left">' . $row['ltd_invoice_no'] . '</td>
       <td align="left">' . $row['ltd_entry_amount'] . '</td>
       <td align="left">' . $row['dr'] . '</td>
    </tr>
    ';
}
echo '</table>';
mysql_free_result ($result); 
mysql_close(); 

if ($num_pages > 1) {
    echo '<br /><p>';
    $current_page = ($start/$display) + 1;

    if ($current_page != 1) {
       echo '<a href="view-list.php?s=' . ($start - $display) . '&np=' .
         $num_pages . '&sort=' . $sort .'">Previous</a> ';   
    }
    for ($i = 1; $i <= $num_pages; $i++) {
       if ($i != $current_page) {
          echo '<a href="view-list.php?s=' . (($display * ($i - 1))) . 
            '&np=' . $num_pages . '&sort=' . $sort .'">' . $i . '</a> ';   
       } else {
          echo $i . ' ';
       }
    }
    if ($current_page != $num_pages) {
       echo '<a href="view-list.php?s=' . ($start + $display) . '&np=' . 
         $num_pages . '&sort=' . $sort .'">Next</a> ';   
    }

    echo '</p>';

} 

?>

<div id="">HTML Content HERE</div>

<?php
include ('./includes/footer.html');
?>

Cheers
Adam

  • 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-05-19T03:00:30+00:00Added an answer on May 19, 2026 at 3:00 am

    Could it be as simple as escaping everything, exiting from the quotes when doing variables? It looks to me like it should work. Can you vardump the $_SESSION[‘ltd_user_id’] somewhere to make sure it is behaving as expected?

    $query = "SELECT `ltd_invoice_no`, `ltd_entry_amount`,  
    DATE_FORMAT(`ltd_entry_date`, '%M %d, %Y') AS `dr`, `ltd_user_id` FROM `ltd_sales_list` WHERE `ltd_user_id` = '".$_SESSION['ltd_user_id']."' ORDER BY
    ".$order_by." LIMIT ".$start.", ".$display;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several members in my class which are const and can therefore only
I intended to create a class which only have static members and static functions.
i have two data classes which hold only data members(no functions). One is CallTask
I have a website which allows members to upload videos, comment on videos, rate
When we have a static method in a class it access only static members
I have a members site where users are given up to 7 web page
I am needing some help with SQL syntax. Say I have a members table,
I'm creating a website that will have the admin upload documents available only to
Suppose I have an ASP.NET website running with its corresponding web.config file, which contains
I am trying to make a members only section on a website. The user

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.