Jump to content


Photo

Populating text form fields from a MySQL database once a user has entered data


  • Please log in to reply
4 replies to this topic

#1 timcclayton

timcclayton
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 22 July 2006 - 09:51 PM

Hello all.

I have a form with 6 text fields in it. When a user enters information in the second text field, I want PHP to "check" a table on my MySQL database for a corresponding record. If it finds a match, then it populates the final 4 text fields with the relevant information from that record (I imagine this "check" needs to be called every time anything is changed in the second text field?).

Can anybody help me (I am fairly new to PHP and MySQL) ?

Many thanks in advance,
Tim.

#2 timcclayton

timcclayton
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 23 July 2006 - 09:27 AM

Sorry to bump this thread, but does anyone know if this is feasible?

#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 23 July 2006 - 10:51 AM

PHP is being run on your server. It's not a client side language, and that means things cant be changed dynamicly.
But, you can use AJAX to do this. When a fields value is being changed AJAX will send the information to the server on the background (without changing any page etc'), get the information back from the server and use this information in any way you want.
Google for AJAX tutorials.

Orio.
Think you're smarty?

(Gone until 20 to November)

#4 timcclayton

timcclayton
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 23 July 2006 - 12:59 PM

Really? Would I be better just doing this in javascript (which I think I will find easier) or does AJAX have advantages over JS

#5 hardyvoje

hardyvoje
  • New Members
  • Pip
  • Newbie
  • 6 posts
  • LocationSerbia

Posted 23 July 2006 - 02:50 PM

You should use combination of JavaScript (fos client side) and PHP/MySQL for Server side

I know how to make it with Flash, because don't use JavaScript...

But, anyway you'll need PHP to check things with database, and some client-side script to trigger PHP when user change data in field.

ok?

if you're using Dreamweaver, check Behaviors panel, there should be some JavaScript behavior for HTML Form fields.
I'm running free design resources portal with photos, illustrations, 3d models, web templates, themes, sounds, loops, tutorials... etc. All resources are public domain - usable in commercial and non commercial projects. check it!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users