Syntax Error with URL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Syntax Error with URL (/showthread.php?tid=75481) |
Syntax Error with URL - GregS - 02-11-2020 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 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. RE: Syntax Error with URL - jreklund - 02-11-2020 Hi, it should be like this: PHP Code: echo '<td><a href="' . site_url("select/gettable/" . $tables['men'][$i]) . '" class="link-class">' . $tables['men'][$i] . '</a></td>'; If it's not working. $tables['men'][$i] contains an array and not a string. |