I have the following data in a MySQL database:
Autonum ID Name MetaValue
1 1 Rose Drinker
2 1 Rose Nice Person
3 1 Rose Runner
4 2 Gary Player
5 2 Gary Funny
I am working in PHP now but I have encountered this problem several times using C#, Java and other languages.
Now my goal in the past and present has been to display the data in the following format:
<table>
<thead>
<th>Name</th>
<th>MetaValue1</th>
</thead>
<tbody>
<tr>
<td>Rose</td>
<td>
<ul>
<li>Drinker</li>
<li>Nice Person</li>
<li>Runner</li>
</ul>
</td>
</tr>
<tr>
<td>Gary</td>
<td>
<ul>
<li>Player</li>
<li>Funny</li>
</td>
</tr>
</tbody>
</table>
I have tackled this problem before by creating a class that represents my SQL table.
Then I created a Dictionary
to hold EmployeeId
and the class.
Dictionary<string,MyTable> MyData = new <string,MyTable>();
Table MyMetaData = new Table();
MyMetaData SomeMetaData=getMetaValueList();//imagine a web service that does that
MyData.add(EmployeeId,SomeMetaData);
I am skipping steps but I hope you get my point. I probably just need keywords of what to call this type of problem. What is the preferred way to accomplish this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…