Retrieving index columns from a table
Posted: Mon Jan 31, 2011 11:27 am
Hello, I am trying to figure out how to automatically retrieve values from a table which are numbered in an index fashion.
Each of these column headings begin as Value then followed by an index so you have:
Country1, Country2, Country3 ....through to Country50.
I would like to have a more automatic way to retrieve these values rather than stick to the
$result .= "<th>$Country1</th>";
But as I have no experience in PHP coding I can only work out the logic. Also not all of these values are populated, so they do not require to be printed if that's the case, so the results could be
<th>Value of Country1</th>
<th>Value of Country2</th>
<th>Value of Country3</th>
<th>Value of Country8</th>
<th>Value of Country24</th>
<th>Value of Country30</th>
I know that I need some sort of array range and a loop to count through to the records, what is the best way of doing this?
Thanks a lot!
Each of these column headings begin as Value then followed by an index so you have:
Country1, Country2, Country3 ....through to Country50.
I would like to have a more automatic way to retrieve these values rather than stick to the
$result .= "<th>$Country1</th>";
But as I have no experience in PHP coding I can only work out the logic. Also not all of these values are populated, so they do not require to be printed if that's the case, so the results could be
<th>Value of Country1</th>
<th>Value of Country2</th>
<th>Value of Country3</th>
<th>Value of Country8</th>
<th>Value of Country24</th>
<th>Value of Country30</th>
I know that I need some sort of array range and a loop to count through to the records, what is the best way of doing this?
Thanks a lot!