Hello
I am just having a problem with the URLS in my For loop. I am trying to get the Table ID when a Link is clicked. Here is the code:
Code:
<?php
$men = 'men';
$women = 'women';
foreach($distances as $distance) {
echo "<div class='row'>";
echo "<div class='col'>";
echo "<table class='table' cellspacing='10' cellpadding='10'>";
echo "<tr>";
echo "<th colspan='2'><h1>" . $distance . "</h1></th>";
echo "</tr>";
echo "<tr><th style='font-size: 20px;'>Men</th><th style='font-size: 20px;'>Women</th></tr>";
for ($i=0; $i<=count($tables['men']); $i++) {
echo "<tr>";
if (substr($tables['men'][$i], -4) == $distance) {
echo '<td><a href="' . site_url("select/gettable/$tables[$men][$i]") . '" class="link-class">' . $tables['men'][$i] . '</a></td>';
echo '<td><a href="' . site_url("select/gettable/$tables[$women][$i]") . '" class="link-class">' . $tables['women'][$i] . '</a></td>';
}
echo "</tr>";
}
echo "</table>";
echo "</div>";
echo "</div>";
}
?>
The problem is with the following line. It has something to do with passing the array $tables['men'][$i]. I am getting the error of Array to string conversion.
Code:
echo '<td><a href="' . site_url("select/gettable/$tables['men'][$i]") . '" class="link-class">' . $tables['men'][$i] . '</a></td>';
When I had it as just:
Code:
echo '<td><a href="' . site_url("select/gettable/$tables") . '" class="link-class">' . $tables['men'][$i] . '</a></td>';
Everything worked perfectly, so I am not sure if I am simply formatting the URL properly, or if you cannot pass arrays to the URL.