Open Source & Stuff  
  |     Main Site     |      Forum     |     Contact     |
Ajax Linked Select boxes :  forum.Salix.gr forum.Salix.gr
Comments, questions, usage, bugs. 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
messageProblem on fields to link
Posted by: demorex6 (IP Logged)
Date: March 11, 2009 02:57PM

Hello,
i'am using Ajax linked select box class,
i have 2 tables i want to link

entreprise(id_entreprise, name_entreprise)
campagne(id_campagne, id_annonceur, name_campagne)

the field 'id_annonceur' is equivalent to 'id_entreprise', so how can i link these fields?
On sql i can write something like:
SELECT id_campagne, id_annonceur as id_entreprise, name entreprise FROM campagne
can i do the same ?

Sorry for bad english, i'm french.
Thanks!

messageRe: Problem on fields to link
Posted by: panos (IP Logged)
Date: March 19, 2009 03:30AM

Hi,

dont worry about your bad english because you are french, few months ago i started using a french php framework and since i like you french ppl more than i used to winking smiley

the trick is done with the link_select_boxes method. The key field of the first table dont have to have the same name with the link field in the second table.
Syntax: link_select_boxes(parent_box_name, child_box_name,
link_field_name, selected_value)

in your case, the key in the first box is id_enterprise as defined in add_select_box method
calling link_select_boxes( box1, box2, 'id_annonceur', 2)
will do select id_campagne, name_campagne from campagne where id_annonceur=2

I hope my english was good enough so you could understand me smiling smiley

best regards
Panos



Sorry, only registered users may post in this forum.

All Rights Reserved 2006 Salix.gr  |  Design by Ades Design |  Hosting by e-emporio |  forum.Salix.gr powered by Phorum