1 Replies - 1607 Views - Last Post: 26 February 2006 - 12:42 AM

#1 ktsirig  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 94
  • Joined: 14-September 05

PHP & Javascript together? HOW TO

Posted 25 February 2006 - 04:42 PM

Hello eveybody!

I am relatively new to PHP and I have no knowledge of Javascript, but I think Javascript might be what I need
for a problem I have.
Well, say you have a PHP page with a form and the forms send a query in the Mysql database,
for example "SELECT name FROM employers WHERE salary > 5000";
The user is then presented with a page containing all the names from the query (this I have done).
What I also want to have is to give the user the ability to click on every person's name and see exactly the amount of salary he gets.
I thought of making an extra php script that would take the person's name as input (when the user clicked on the name) and then show the salary.
But I want to use pop-up window for this job, so I think Javascript is best for that...
Any hints on how to start? Basically I need some hints on how to get something fro a page and give it as input to Javasript to do the rest of the job...

Is This A Good Question/Topic? 0
  • +

Replies To: PHP & Javascript together? HOW TO

#2 cyberscribe  Icon User is offline

  • humble.genius
  • member icon

Reputation: 10
  • View blog
  • Posts: 1,062
  • Joined: 05-May 02

Re: PHP & Javascript together? HOW TO

Posted 26 February 2006 - 12:42 AM

Traditionally, you would do all the heavy lifting in PHP, with either two different pages (i.e. files with PHP code) or two different "modes" (view all records and view details of one record) in the same page and/or file. If you want to go the traditional route (which I recommend if you're starting out), Javascript just comes into play to open the new popup window. But the window it opens activates a page with PHP code to do the work. You could acheive a similar effect of opening a new window (but not immediately control properties like scrollbar, url bar, etc.) by using target="_blank" in your reference to the detailed view PHP script.

Other, more advanced applications could involve Javascript and PHP in a methodology commonly called AJAX. These so-called "Web 2.0" applications involve interactions between PHP and Javascript to retreive data and re-write sections of the web page on the fly, so you don't actually have to re-POST or re-GET the entire page each time you want to display new data. That, however, is a more advanced topic... ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1