Link to home
Start Free TrialLog in
Avatar of kbios
kbios

asked on

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.
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

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.
Avatar of kbios
kbios

ASKER

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?
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.
Avatar of kbios

ASKER

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.

ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kbios

ASKER

Thanks for you help.