• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

How do I retreive data from mysql that I can use in HTML/javacript?

I have a web app that successfully uses php/ajax to populate some tables in a mysql database. The shopping cart application creates a header record and multiple item records.

After the data is loaded into the mysql db I would like to 'verify' the upload. I would like to launch another php to select the item records and verify that the number of items that I 'uploaded' is the exact number of line items in the database. I would like to retreive the number of item records selected and then compare this number against the number of items that I 'uploaded'. I would then generate the appropriate success or fail messages.

I'm looking for some thoughts/ideas on the best way to accomplish this. Thanks in advance for any assistance.
0
kbios
Asked:
kbios
  • 3
  • 3
1 Solution
 
COBOLdinosaurCommented:
It would be a good idea to post the php you are using to process the transaction, so we get some idea of the structure of the data.  Otherwise you are just going to get vague guesses; if you get any response at all.
0
 
kbiosAuthor Commented:
A vague guess may be helpful. The php code is standard code that does an INSERT INTO a mysql table.

Let's say MySql table has multiple item records for a specific. I do some mysql record count and now I have a php variable $reccount = 3

The question I have is how can I get, retrieve or reference the server-side variable $reccount back on the client-side so I can compare/verify the proper number of records were uploaded?
0
 
COBOLdinosaurCommented:
How does it help you on the client side? Once the data is sent back to the client, it is out of your control.  You can have a javascript check the number but there cannot be any confidence level because the browser will be getting a new page with both numbers generated from the same source.

Verification has to be on the server side with a select using the same keys that were used to insert the rows.  Quite frankly the whole thing is redundant.  A real audit of the transaction would involve a second script that test the data. If the first transaction did not return an error, then the only way there could be a difference is if the php has a bug inwhich case many transactions would be wrong or the database is corrupt in which case nothing using the database would be producing correct results.
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
kbiosAuthor Commented:
On the client-side I have a localStorage variable that contains the number of line items that should be written to the mysql db. The php creates the mysql db properly with no errors. However I would like to compare the record count of the mysql table against the client-side variable.

0
 
COBOLdinosaurCommented:
You have to check it on the server. If you don't the client side variable then pass it as part of the transaction.  Then after you insert the rows to the DB, do a select against the DB and see if the count matches.  The best you can do is confirm to the client that the transaction completed without error and return the count you get off of the select.

If you have control of the DB server side that is the place to do the check.  If you control processing server side that is where you need to program the audit function.  The client cannot directly interact with the DB, and I guarantee you that you would not want it to have that capability.
0
 
kbiosAuthor Commented:
Thanks for you help.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now