SchweppesAle Posted April 6, 2009 Share Posted April 6, 2009 hi, I was wondering if it's possible to take all the input values then store them within array which I can pass onto a script which will handle it. The reason I'm doing this is because I have a script which will generate a different number of "checkbox" input types depending on how large the database has grown and I'm not sure how to pull these values since you need to declare the name of each input. ex: $_GET["name"] I figured that if I could store them all within a single array then there wouldn't be a problem. Is there a better way of doing this? edit: just wanted you guys to get an idea of what I'm working with <?php global $mainframe; $db =&JFactory::getDBO(); $query = "SELECT * FROM #__AuthorList"; $db->setQuery( $query, 0, $count ); $rows = $db->loadObjectList(); $number = 0; echo "<form method='get' action='script name'>"; echo "<table border = 1 width = 500><tr><td>"; echo "<center><b>Primary List</b></center>"; echo "</td></tr>"; foreach($rows as $row) { if (($row -> stage) == 0 && (($row -> AuthorName) != LeaveBlank) && (($row -> AuthorName) != null)) { echo "<tr><td>"; echo $row ->AuthorName; echo "</td><td>"; echo "<input type='checkbox' name='".$row->AuthorID."' value='".$row->AuthorID."'>"; echo "</tr></td>"; } } echo "</table>"; echo "<p/>"; echo "<table border = 1 width = 500><tr><td>"; echo "<center><b>Secondary List</b></center>"; echo "</td></tr>"; foreach($rows as $row) { if (($row -> stage) == -1 && (($row -> AuthorName) != LeaveBlank2) && (($row -> AuthorName) != null)) { echo "<tr><td>"; echo $row ->AuthorName; echo "</td><td>"; echo "<input type='checkbox' name='".$row->AuthorID."' value='".$row->AuthorID."'>"; echo "</tr></td>"; } } echo "</table>"; echo "<p/>"; echo "<input type='hidden' name='number' value='".$number."'>" echo "<INPUT type='submit' value='Switch Current List'>"; echo "</form>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/152885-solved-php-post-can-you-store-these-variables-into-an-array/ Share on other sites More sharing options...
wildteen88 Posted April 6, 2009 Share Posted April 6, 2009 You can name your checkboxes as name[] that way when the form is submitted all checkbox values will be held within the $_GET['name'] array Quote Link to comment https://forums.phpfreaks.com/topic/152885-solved-php-post-can-you-store-these-variables-into-an-array/#findComment-802900 Share on other sites More sharing options...
Maq Posted April 6, 2009 Share Posted April 6, 2009 You need to give the checkboxes the same name. Something like: name='authorid[]' Quote Link to comment https://forums.phpfreaks.com/topic/152885-solved-php-post-can-you-store-these-variables-into-an-array/#findComment-802902 Share on other sites More sharing options...
SchweppesAle Posted April 6, 2009 Author Share Posted April 6, 2009 lol, alright I guess I can try that Quote Link to comment https://forums.phpfreaks.com/topic/152885-solved-php-post-can-you-store-these-variables-into-an-array/#findComment-802912 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.