Click here to Skip to main content
13,055,852 members (50,420 online)
Rate this:
Please Sign up or sign in to vote.
After inserting a record to a MySQL database I want to view a message that the record adding is successful by not using .php but using JavaScript. I want to do that to view the message in the client's side i.e the web browser.
Posted 22-Feb-12 21:01pm
SAKryukov 23-Feb-12 3:18am
Why? How Javascript can know your MySQL data? Do you really understand what Javascript does? I'm not sure.
Chiranthaka Sampath 23-Feb-12 6:09am
After insert one record gives '1 record added' message in php. But I want to display that message like a message box using javascript(an alert).
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Ajax[^] is your friend!

No matter what, you will have to handle the database interactions in the server side, i.e. using PHP.

You will have to invoke the database operation using a Javascript HTTP request, and make the PHP code in server do the real operation in the database. After that, send the result back to the client as the normal HTTP response. And then you can display a nice little message box to the user using Javascript.

But, forget everything and read that tutorial I gave you, (if you don't know about Ajax, of course). And you'll find a way doing it then.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Ok pals I got the solution by my self. The solution is mentioned at the bottom.

echo ''


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 23 Feb 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100