n!ch0
2012-11-20 20:29:44 UTC
I have an intermediate knowledge of PHP, working with mySQL, creating methods and classes, etc. Like most people, I'm self taught, so certain things I can't grasp without an explanation, or without seeing an example written by someone else.
A few years ago I was working on a Content Management System. It took me 3 months. Everything worked very well, I had even created my own WYSIWYG Editor, but the actual coding was VERY "rookie". I'm currently re-writing my CMS uses Classes so everything is re-usable.
(QUESTION)
One thing I'm confused on is echo'ing a result to the same page. Can this be done in PHP? Or do I need to incorporate an additional language, such as AJAX?
(EXAMPLE)
Say I have a functions.php page that contains the following:
function displayResults() {
echo "hello world!";
}
and I have a link (for example) on index.php, that when clicked, echo's "displayResults()" to a div element named "results".
(ADDITIONAL EXAMPLE - IF THE FIRST ONE WASN'T CLEAR ENOUGH)
insert.php contains a submit button that when clicked, calls the page "actions.php". "actions.php" perfoms the action to insert the data to the database. On this same page is a method that echo's whether or not the action was successful. I want that "echo" to target a specific div element on "insert.php" and NOT take the user to a blank page with the echo'd results.
(MORE BLAH BLAH)
This is just a basic explanation of course. I've done similar things when I was first learning JavaScript 10 years ago, but since I working with a mySQL database, I don't want to have to switch back and forth between languages.
(HOW YOU CAN HELP ME)
If the code is too complex to explain, for whatever reason, please provide a pseudo code solution.
Thank you!