Re: How to limit dropdown list to options based on 'in use' rows from lookup table, for webpage using php and postgresql

Killian Driscoll <[email protected]> Tue, 29 Dec 2015 17:44:09 +0100
Newsgroups gmane.comp.db.postgresql.php
Message-ID <CAL64pZMtFdiHjtMPxBRcFj+5mV8yEP0SsoyK6YVg6=Q_ZvWxSg@mail.gmail.com>
--94eb2c06c23a95627605280c228d
Content-Type: text/plain; charset=UTF-8

On 29 December 2015 at 17:35, Raymond O'Donnell <[email protected]> wrote:

> On 29/12/2015 16:23, Killian Driscoll wrote:
> > I have a table country with a lookup table to country_type.
> >
> > table country
> >
> > country_id (pk), col2, col3, country_type_id (fk) integer
> >
> > lookup table
> >
> > country_type country_type_id (pk), type_name varchar
> >
> > My lookup table has 50 country types, but only 20 are 'in use' in the
> > current db (with the rest possibly used later as the db expands). On the
> > webpage I am creating (I am using a php generator) I can set it up to
> > add a filter by country type based on the country type_name varchar - so
> > one can view the country types by name rather than the id integer - but
> > all 50 types are listed.
> >
> > I only want the 20 that currently 'in use' (not sure if this is the best
> > way to describe it) and therefore relevant to searches/filters (i.e. I
> > don't want to see a "There are no records to display" message).
>
> How do you define "in use"? Is it a switch turned on and off by an
> admin? is it based on how often that country is chosen by a user? Maybe
> something else?
>

Apologies - 'in use' is my grasping at describing it, and as I guessed it
was unclear. By 'in use' I mean that from my 50 lookup options for county
types, to date in the db only 20 country types have been used, i.e. my db's
countries are of 20 types, e.g. country 1 is type 'glorious', country 2 is
type 'barren', but no country so far is type 'lucky': when one uses the
webpage filter I only want the type lookups used to date to be seen, i.e.
'glorious' or 'barren', but not 'lucky' as the latter would result in a "There
are no records to display" message.

>
> Ray.
>
> --
> Raymond O'Donnell :: Galway :: Ireland
> [email protected]
>

--94eb2c06c23a95627605280c228d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 29 December 2015 at 17:35, Raymond O&#39;Donnell <span =
dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]<=
/a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quo=
te"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bor=
der-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=3D"">On 2=
9/12/2015 16:23, Killian Driscoll wrote:<br>
&gt; I have a table country with a lookup table to country_type.<br>
&gt;<br>
&gt; table country<br>
&gt;<br>
&gt; country_id (pk), col2, col3, country_type_id (fk) integer<br>
&gt;<br>
&gt; lookup table<br>
&gt;<br>
&gt; country_type country_type_id (pk), type_name varchar<br>
&gt;<br>
&gt; My lookup table has 50 country types, but only 20 are &#39;in use&#39;=
 in the<br>
&gt; current db (with the rest possibly used later as the db expands). On t=
he<br>
&gt; webpage I am creating (I am using a php generator) I can set it up to<=
br>
&gt; add a filter by country type based on the country type_name varchar - =
so<br>
&gt; one can view the country types by name rather than the id integer - bu=
t<br>
&gt; all 50 types are listed.<br>
&gt;<br>
&gt; I only want the 20 that currently &#39;in use&#39; (not sure if this i=
s the best<br>
&gt; way to describe it) and therefore relevant to searches/filters (i.e. I=
<br>
&gt; don&#39;t want to see a &quot;There are no records to display&quot; me=
ssage).<br>
<br>
</span>How do you define &quot;in use&quot;? Is it a switch turned on and o=
ff by an<br>
admin? is it based on how often that country is chosen by a user? Maybe<br>
something else?<br></blockquote><div>=C2=A0</div><div>Apologies - &#39;in u=
se&#39; is my grasping at describing it, and as I guessed it was unclear. B=
y &#39;in use&#39; I mean that from my 50 lookup options for county types, =
to date in the db only 20 country types have been used, i.e. my db&#39;s co=
untries are of 20 types, e.g. country 1 is type &#39;glorious&#39;, country=
 2 is type &#39;barren&#39;, but no country so far is type &#39;lucky&#39;:=
 when one uses the webpage filter I only want the type lookups used to date=
 to be seen, i.e. &#39;glorious&#39; or &#39;barren&#39;, but not &#39;luck=
y&#39; as the latter would result in a <span class=3D"">&quot;There are no =
records to display&quot; message.</span> </div><blockquote class=3D"gmail_q=
uote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,2=
04);padding-left:1ex">
<br>
Ray.<br>
<span class=3D""><font color=3D"#888888"><br>
--<br>
Raymond O&#39;Donnell :: Galway :: Ireland<br>
<a href=3D"mailto:[email protected]">[email protected]</a><br>
</font></span></blockquote></div><br></div></div>

--94eb2c06c23a95627605280c228d--