11 Replies - 4720 Views - Last Post: 29 May 2009 - 08:20 AM Rate Topic: -----

#1 kunkka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 99
  • Joined: 15-May 09

how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 04:22 AM

in my registration page i have a combo box in the top. so the user will select the perticular item and insert the other details and enter. then it should goes to Table 1.

and if another user logs and select a differnt item from the Combo box it should goes to another Table. called Table2.

pls help me. how to use the list box for that. how to check it
Is This A Good Question/Topic? 0
  • +

Replies To: how to use combo box and insert data to differnt tables

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 05:25 AM

Data is sent via post or get. It's your job as the programmer to take that data and do what needs to be done with it. Since you've posted no code, I can't say why it isn't working for you.
Was This Post Helpful? 0
  • +
  • -

#3 kunkka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 99
  • Joined: 15-May 09

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 05:39 AM

im using POST.

what i want is how to use combobox in php
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 05:45 AM

I don't understand. You've got a form with multiple inputs that posts the data, so what's the problem?
Was This Post Helpful? 0
  • +
  • -

#5 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 06:35 AM

The data comes back in the post index that is the combo box's name.
If your combo box's name was "Tim" (Awesome name for an unrealistic object, by the way) then the data returned to you from the user form's combo box would be in $_POST['Tim'].

Hope that helps you understand the concept.

Yours,
Shane~
Was This Post Helpful? 0
  • +
  • -

#6 kunkka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 99
  • Joined: 15-May 09

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 07:44 AM

Thanks a lot

but tell me if i select like this

if(isset($_POST['usertype']='Student'))


what this mean is if the user select Student from the Combo box named usertype ?


but this is not working..
Was This Post Helpful? 0
  • +
  • -

#7 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 07:49 AM

That code is pretty warped, you tried to set the variable while, at the same time, checking to see if it's set....
If you wanted your code to work you'd say something like:
if(isset($_POST['usertype']) && $_POST['usertype'] == 'Student'){


Yours,
Shane~

This post has been edited by ShaneK: 29 May 2009 - 07:52 AM

Was This Post Helpful? 0
  • +
  • -

#8 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 07:50 AM

This
if(isset($_POST['usertype']='Student'))

should be something like this:
if(isset($_POST['usertype'])) {
  if($_POST['usertype'] == 'Student') {


First you test to see if that post has been set, then if it has, what it has been set to.

Note that = is assign, and == tests.
Was This Post Helpful? 1
  • +
  • -

#9 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 08:04 AM

View PostShaneK, on 29 May, 2009 - 10:49 AM, said:

if(isset($_POST['usertype']) && $_POST['usertype'] == 'Student'){

If you're going to do that, why not just do:
if($_POST['usertype'] == 'Student'){

since you're testing that no matter what?

I think the only time you want to use isset is when you might need to test multiple possibilities:

if(isset($_POST['usertype'])) {
  if($_POST['usertype'] == 'Student') {
	// do something
  elseif($_POST['usertype'] == 'Parent') {
	// do something else
// etc.


That way, you don't do multiple tests if $_POST['usertype'] isn't set.
Was This Post Helpful? 0
  • +
  • -

#10 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 08:10 AM

I believe the parser stops testing if it's an AND statement and the first one is false, but I'm not even sure. (That's what I was told once.)

But your method is much better anyway, I don't use isset() much so I really have no need for this.

Yours,
Shane~
Was This Post Helpful? 0
  • +
  • -

#11 kunkka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 99
  • Joined: 15-May 09

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 08:11 AM

Thanks a lot.. appreciate the support a lot
Was This Post Helpful? 0
  • +
  • -

#12 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: how to use combo box and insert data to differnt tables

Posted 29 May 2009 - 08:20 AM

View PostShaneK, on 29 May, 2009 - 11:10 AM, said:

I believe the parser stops testing if it's an AND statement and the first one is false, but I'm not even sure. (That's what I was told once.)

It should, but I don't know either. I just figure that if it is set, then you still have to test its value, so you might as well just test the value and be done with it. After all, if it isn't set, then the value won't be what you're looking for!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1