Forums

Fill text box from sql select

NickOg 10 Sep, 2011
I really have tried to work this out but just can't! It is so obvious and straight forward that I must be missing something.

I have a table - 'species' - that has a field `plantTypeID` that contains a link to a key in a look up table of plant types - `lupPlantTypes` that contains fields `plantTypeID` & `plant_type`.

I want to display the field `plant_type`in my form based on the value of `plantTypeID` stored in the species table `species`. So I have SQL 'SELECT `planttype` FROM `lupPlantTypes`,`species` WHERE `lupPlantTypes`.`plantTypeID` = `species`.`plantTypeID`'.

All very simple but my questions are:

[list]Where do I put the select code (wrapped in PHP of course)? In a Custom Field or a Text Box? If the latter, where in the configuration box.[/list]
[list]How do I then reference the derived value from the select code in the form? That is, how do I reference a generated value rather than a value read from the database?[/list]
[list]Then for the edit version of the form, how do I populate a select box from a select query. 'SELECT 'planttype' FROM `lupPlantTypes`[/list]
[list]And then again, how do I set the field in the editor to take the selected id value?[/list]

It has to be simple and straight forward (I can write the PHP code to deal with the SELECT code) but where do I put it? It has to be somewhere in the forum but damned if I can find it.

Can anyone help me? Are there specific posts out there that answer this?

Help!!lightbulb :? :?
NickOg 11 Sep, 2011
:oops: 😶 😶
Please forget or drop this post. A mental block now cleared and all sorted.

:mrgreen: :mrgreen:
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger