Jump to content

help with data output


jag

Recommended Posts

i\'m stuck on a data output problem. i\'m accessing a mysql database and retrieving all the row data. there are 3 fields - UID, SID, Answer

 

i\'m connecting and getting the data just fine. the problem is that there are multiple rows with the same UID and the data prints just like that. here\'s a sample:

 

83332091781424;2;felwick01

83332091781424;2;x

83332091781424;2;N1

83332091781424;2;N1

83332091781424;2;N1

83332091781424;2;N2

39808168103209171;2;felwick02

39808168103209171;2;x

39808168103209171;2;N2

39808168103209171;2;N1

39808168103209171;2;N4

39808168103209171;2;N6

 

 

what i need is only 1 instance of the UID, 1 instance of the SID, and then all the Answer field for each UID printed in a continuous row. example -

 

83332091781424;2;felwick01;x;N1;N1;N1;N2

39808168103209171;2;felwick02;x;N2;N1;N4;N6

 

any help would be *greatly* appreciated!

Link to comment
https://forums.phpfreaks.com/topic/625-help-with-data-output/
Share on other sites

Hi,

 

This can NOT be done in sql, since you want a variable number of rows returned and printed on one line.... It\'s a LOT easier to parse your output in php, and return what you want. (Or any other language, perl, basic, fortran whatever... )

 

On each new line>

while grab line {

 

if UID = UID above, nothing ELSE print UID

if SID = SID above, nothing ELSE print SID

print field3;

 

}

 

will do it, format to any language...

 

P.

Link to comment
https://forums.phpfreaks.com/topic/625-help-with-data-output/#findComment-2099
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.