FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Dynamic field names in recordset
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Dynamic field names in recordset [message #169680 is a reply to message #169676] Wed, 22 September 2010 15:53 Go to previous messageGo to previous message
Pedro M. Leite is currently offline  Pedro M. Leite
Messages: 5
Registered: September 2010
Karma:
Junior Member
forgot : php + mysql

On 09/22/2010 03:33 PM, Robert Hairgrove wrote:
> Pedro M. Leite wrote:
>> good afternoon
>>
>> sorry if i not make my self clear
>> current situation
>> one table with 50 fields - appx
>> id - name - entrydate - remarks - width .... locked
>> one page with :
>> select from table where id = " - from $_GET
>> read the recordset and output pdf
>> rst_table['id']
>> rst_table['name']
>> rst_table['entrydate']
>> ....
>> rst_table['locked']
>>
>> 50 something times repeated
>>
>> now, i want to have a table with
>> fieldname
>> position
>> so that i can :
>> open a recordset from table with one row
>> browse the position table, ordered by index, from 1 to 50 something
>> in the loop, make
>> (pseudocode) echo_to_pdf rst_table(position_table(fieldname))
>> loop
>>
>> so that, to rst_table, the field i want is passed bu the content of the
>> position_table field content, instead of literally :
>> 'position_table(fieldname)'
>>
>> simple example
>>
>> main table
>> id
>> name
>> remarks
>>
>> position table
>> id,1
>> name,2
>> remarks,3
>>
>> so the output is : id - name - remarks
>>
>> OR
>>
>> position table
>> id,1
>> name,3
>> remarks,2
>>
>> so the output is : id - remarks - name
>>
>> s, what i am looking to do is to reference the field by another
>> reference and not literally
>>
>> thank you in advance
>> Pedro Leite
>
> You didn't specify what database you are using ... with most relational
> databases (MySQL, Oracle, etc.) you can (and should!) refer to the field
> by name and not by position.
>
> You should not depend on the position of a column within a table! Most
> of the time, the DBA is NOT the same person who is programming the
> client application. So, what happens if someone adds a column to the
> table, and doesn't tell you about it? Your code breaks, of course.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How do we manage large code sets in PHP?
Next Topic: Book problems and solution for windows 7
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 01:41:30 GMT 2024

Total time taken to generate the page: 0.04344 seconds