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!
Retrieving index columns from a table
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Retrieving index columns from a table
Show your database query code.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Retrieving index columns from a table
It's not a database but an excel sheet. I also forgot to mention that each <th> must also contain the id of the country which will eventually be better converted as an array i.e.
<th id="Country30">data for country30</th>
<th id="Country48">data for country 48</th>
<th id="Country49">data for country 49</th>
Does that make sense?
<th id="Country30">data for country30</th>
<th id="Country48">data for country 48</th>
<th id="Country49">data for country 49</th>
Does that make sense?