Forum Moderators: coopster
I often use id's of other tables in my database to represent the information. For example:
Table: phone number types
id ¦ type
---------------
1 ¦ Home
2 ¦ Work
3 ¦ Fax
Table: people's phone
id ¦ person ¦ number ¦ type
-------------------------------
1 ¦ Sue ¦ 5551212 ¦ 2
On the people's phone table I assign a type id instead of the actual type. So everytime I want to list Sue's work number the table pulls the number then the number 2.
I want to create a function or an array so I only have to pull data from the phone number type table once per page, then simply compare the id fields to display the actual type.
Right now I query the people's table, then within each output I run a query to pull the id of the phone type and display the associated text. This is very wasteful.
Can you help me figure out a faster way? Perhaps a function or stored array.
Thanks,
Ofie
Can you help me figure out a faster way?
Can you outline your process a bit more... The most important question I can see needing the answer to is: Do you need to access the phone number on different pages or only one page? If you only need it on one page, then do as mooger35 suggested or something similar. Access the information once (at the top of the code) then use it throughout the code while you build the page. If you need to display it when a visitor is on Page A, then again on Page B and so on, then you have some options rather than making a query every time, but they're fairly limited.