Trying to display all records for a specific customer

The system I found does not join the customer table to the invoice table which is bit silly so I have had to join it myself, I have added customer_id column onto the invoice table

I’ll need to then write the insert query to include the customer_id and a select dropdown with the customer id and the name for the new order page so it inserts the customer id to the invoice table.

I’m not great at writing my own queries, I can do some or most of it but it’s working out what is needed, on the phpmyadmin side I can work out but it’s when it’s on the php page it don’t work

If you shared an example of that, showing the query as it executes in phpmyadmin and your code in PHP, I’m sure someone would be able to figure out what the problem is so that you can make progress.

That’s putting it mildly - an invoicing system that doesn’t store the customer against each invoice is useless. Do you have a link to it? If it’s missing something as basic as this, perhaps there are other issues that make it pointless spending time on.

The link to the system I found and trying to amend is https://www.sourcecodester.com/php/14540/point-sales-phppdo-full-source-code-2020.html

I have managed to get the customer linked to the order/invoice I think

I can send the link to the system on my server by a private message if that’s possible to do on here

No need, I wasn’t asking for a link to your system, just to the downloaded project you’re using.

The reason it doesn’t have a reference to the customer table in the invoice table is that it doesn’t seem to have a customer table. There’s no customer record anywhere in the system that I can see, it seems to be designed for a shop that doesn’t keep customer records.

It stores passwords in plain text in the database, which is a pretty good reason not to go any further with it. Despite talking about PDO, it also doesn’t use prepared statements, instead it sticks strings directly into the query. It uses prepare() but not properly:

$id = $_GET['id'];

$delete_query = "DELETE tbl_invoice , tbl_invoice_detail FROM tbl_invoice 
INNER JOIN tbl_invoice_detail ON tbl_invoice.invoice_id =
    tbl_invoice_detail.invoice_id 
WHERE tbl_invoice.invoice_id=$id";
$delete = $pdo->prepare($delete_query);

If you need it to keep invoices against customers, you’ll need to add all the customer create / modify / delete code and then change it to raise invoices / take payments against each customer.

I was going to sort the passwords issue so they are secure in the database as know plain view passwords are never good

I know PDO is better than mysqli but can’t find a system that is PDO, I’ll need to have another look and try and find one

Might be better to try and find a netter coded system that uses PDO and secure passwords and one that has customers linked to invoices and stores invoice items in a seperate database table to the invoice database table

Is there any links to systems you recommend to use please?

What is your overall goal for doing this? To learn making a complete application? To learn basic Create, Read, Update, Delete (CRUD) database operations? To learn using the PDO database extension?

Just trying different things and throwing them away when they don’t work, without learning the good things to keep and the bad things to avoid, is a huge waste of time. Most of the code posted on the Internet is there, not to teach, but for the ad revenue from the page visits. The last linked to code may have gotten a passing grade in a programming class, because it produced all the web pages it was supposed to, but it is lacking in proper programming practices, security, and consistency. It is not even halting php code execution on the administrator pages after the permission check redirect, so the pages are still accessible, just by ignoring the redirects.

The overall goal is to create a system for someone I know who asked if I can create it for them. It started off as a basic system which I was able to do but they want it more advanced now

Sorry, I don’t have any links to stuff like this. If I was doing what you’re doing, I’d write the code.

I’m not sure what you mean by that - the system you linked to uses PDO as you can see in the connect_db.php file, it just doesn’t make use of features like Prepared Statements properly.

Is it really better to get rid of what they have now and start again on something new, than for you to modify what you’ve already done to take in their extra requirements? Obviously we don’t know what the basic system is lacking from their new needs, but ditching working code always seems wasteful unless it’s more time-consuming to modify it than start again.

It sounds like the code needs rewriting to make full use of the features such as the prepared statements properly, I’ll probably need help on that.

They don’t have nothing in place now, it’s all done by pen and paper I think but would like a web based system.

There was a lot of features they want adding into the basic system I built such as they want TAX/VAT added on the total order/invoice total and delivery charges for various items for example 50p/bag for delivery, 25p/beg of Logs, Kindling, Pellets and also wanted it integrated with a cash drawer and printer so they can print off a receipt in store if a customer collected the order in their store and they want credit account option for businesses and have a invoice emailed from the system, they want a sales report generated at the end of each day to show what was sold & the breakdown of cash, card & account, they want VAT breakdown on receipts especially for orders on account for businesses. But would really need it on all receipts, they want on the order page to select a customer and it will auto detect that they would be assigned to the Lorry for Lochs Monday rather than having to do that manually, lastly they want to generate a report at the end of each day that they can enter into Sage or Xero to show their sales & VAT, etc

So, they basically want a full accounting system with a few extra features such as which delivery round the customer is on, which may be straightforward these days.

That’s a fairly major undertaking, and once you get involved in stuff like VAT you need to be sure you’re keeping proper records. What part of that is something like Xero unable to do? I’ve only used it from the API point of view, sending information from my customers POS system into Xero for their accountant to produce reports, file tax returns etc.

Yeah sounds like they do from the requirements they sent me after I did the basic system for them as their original brief was more basic but then they added the more difficult features etc in

I’ve not used xero etc before so may need a developer to help on that side of it

Northwind Database created for MS Access tutorial since late 90s, is a good example of a normalized database for a fictitious business. It’s so good that it has been ported to many different types of databases.

Here is a MySQL port that you can use for your project.

Thank you, that could be good to use

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.