Jump to content


Photo

How to query a database before Posting


  • Please log in to reply
4 replies to this topic

#1 jamesnkk

jamesnkk
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 16 March 2006 - 05:40 PM

Hi, I am a newbies here, just started learning PHP, Could not find an answer to my requirement, hope some experts can offer help.

Here I have an entry from for entering Part numbers, description, price and qty so on...
So when a user enter a part number, I would want to immediate check if this part numbers already exist before the user click the submit button to post.


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 16 March 2006 - 05:55 PM

That can only be done via Javascript and AJAX.

Ken

#3 jamesnkk

jamesnkk
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 16 March 2006 - 06:09 PM

[!--quoteo(post=355599:date=Mar 17 2006, 01:55 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 17 2006, 01:55 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
That can only be done via Javascript and AJAX.

Ken
[/quote]

Ken, Thank for your fast response, do you mean I can only use javascript to query the table ?, and not possible in PHP ?

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 16 March 2006 - 06:33 PM

You can do this both ways.

1) You can have them enter a part number and give them a button. The button submits the form and either takes them to a second form where they fill in additional information about the part to be submitted for insertion, or it takes them to a page that says the part already exists.

2) Same as above, but you use AJAX to return the results. If you don't understand what AJAX is, check out www.ajaxfreaks.com (a sister site of phpfreaks). It's a javascript call that can run a PHP script that will return data to a specified area of your page without reloading the page.

I'd personally go with AJAX, but it requires the user to have Javascript enabled to use the functionality of the site.

Info: PHP Manual


#5 jamesnkk

jamesnkk
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 16 March 2006 - 07:08 PM

[!--quoteo(post=355614:date=Mar 17 2006, 02:33 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 17 2006, 02:33 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You can do this both ways.

1) You can have them enter a part number and give them a button. The button submits the form and either takes them to a second form where they fill in additional information about the part to be submitted for insertion, or it takes them to a page that says the part already exists.

2) Same as above, but you use AJAX to return the results. If you don't understand what AJAX is, check out www.ajaxfreaks.com (a sister site of phpfreaks). It's a javascript call that can run a PHP script that will return data to a specified area of your page without reloading the page.

I'd personally go with AJAX, but it requires the user to have Javascript enabled to use the functionality of the site.
[/quote]
Thank for the advises, well consider




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users