sethkain Posted July 27, 2007 Share Posted July 27, 2007 I have searched for an answer to this and didn't find anything specific to what I am trying to do. Hopefully I am just missing something small. In my db are multiple tables all with the same layout. They all contain: id, name. For the 'floor' table it contains (floor_id, floor). I am looping through all the tables with one query statement. And then displaying each table's data with checkboxes. On the next page I want to implode the array for each table. Then store all of them in a separate table. Everything works, except the checkbox name as an array. I get an error when i do this: echo"<td><input type='checkbox' name='$tablename[]' value='$tablenameid' />$variablename</td>"; But if i change it to this: echo"<td><input type='checkbox' name='tablename[]' value='$tablenameid' />$variablename</td>"; It works just fine. But then there is just ONE big array called tablename. Quote Link to comment Share on other sites More sharing options...
marcus Posted July 27, 2007 Share Posted July 27, 2007 Use the checkbox [2nd try] and just pass it, then use foreach. $tblname = $_POST['tablename']; foreach($tblname AS $woah){ echo $woah . "<br />\n"; } Quote Link to comment Share on other sites More sharing options...
ss32 Posted July 27, 2007 Share Posted July 27, 2007 i think you are going to have to escape the string for this one (= ..." . $tablename . "[] ... Quote Link to comment Share on other sites More sharing options...
sethkain Posted July 27, 2007 Author Share Posted July 27, 2007 ss32 that worked great. I actually tried something similar earlier, but I must have gotten it wrong somehow. One more issue. When i try to loop through taking each array and imploding it into a string: $tables = array("style", "parking", "construction", "foundation"); foreach ($tables as $tablename) { $tablenamestring= implode(",", $tablename); echo ($tablenamestring); } I get this error message: Warning: implode() [function.implode]: Bad arguments. But when i change the code to this: foreach ($tables as $tablename) { $tablenamestring= implode(",", $style); echo ($tablenamestring); } it works fine. Quote Link to comment Share on other sites More sharing options...
sethkain Posted July 27, 2007 Author Share Posted July 27, 2007 when this code executes: $tables = array("style", "parking", "construction", "foundation"); foreach ($tables as $tablename) { $tablenamestring= implode(",", $tablename); echo ($tablenamestring); } This line: $tablenamestring= implode(",", $tablename); Executes as this: $tablenamestring= implode(",", style); Well duh that is why i was getting Warning: implode() [function.implode]: Bad arguments. Changed code to: $tablenamestring= implode(",", $$tablename); Works fine. Hope this helps someone in the future. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.