sigmahokies Posted June 25, 2015 Author Share Posted June 25, 2015 Cronix and Jazzman1, here my update script in PHP. Jazzman1, I tired your code, seem it doesn't work. I get error in 13th line <!doctype html> <html> <head> <title>Test array attendence</title> </head> <body> <table border="1"> <?php if (!empty($_GET['member'])) { $data = $_GET['member']; foreach (array_chunk($data, 2) as $row): <-- 13th line ?> <tr> <?php foreach ($row as $value): ?> <td><?php echo htmlentities($value); ?></td> <?php endforeach; ?> </tr> <?php endforeach; }else { echo "Fail to get data from previous"; } ?> </table> <table><tr><td><?php echo count($_GET['member'])." are attending this meeting tonight." ?></td></tr></table> </body> </html> I get result: Warning: array_chunk() expects parameter 1 to be array, string given in /srv/disk10/1141650/www/sigmahokies.biz.ht/testarray3.php on line 13Warning: Invalid argument supplied for foreach() in /srv/disk10/1141650/www/sigmahokies.biz.ht/testarray3.php on line 13 Those are error message. Hope to hear from you soon Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/page/2/#findComment-1514870 Share on other sites More sharing options...
CroNiX Posted June 25, 2015 Share Posted June 25, 2015 It boils down to $_GET['member'] is not an array, so it's breaking the array_chunk() function which only works on...arrays. Where is 'member' coming from in the GET request? A form? A custom built url? Post how that is generated. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/page/2/#findComment-1514914 Share on other sites More sharing options...
sigmahokies Posted June 26, 2015 Author Share Posted June 26, 2015 Cronix, That 'member' is come from first page that has name='member' that should transfer value to second page. it is on thread in here on first page, but I better post my first page... Here my code: <!doctype html> <html> <head> <title>Test array with columns</title> </head> <body> <form action="testarray3.php" method="GET"> <fieldset> <?php $column = 2; $Garydb = mysqli_connect('XXXXX','XXXXX','XXXXX') or die("Could not connect to database."); mysqli_select_db($Garydb, 'XXXXX'); $sql = "SELECT CONCAT(FirstName,' ',LastName) AS Name FROM Members ORDER BY LastName ASC"; $result = mysqli_query($Garydb, $sql); $num_rows = mysqli_num_rows($result); $rows = ceil($num_rows / $column); while ($row = mysqli_fetch_array($result)) { $data[] = $row['Name']; } echo "<table border='7'>\n"; for($i = 0; $i < $rows; $i++) { echo "<tr>\n"; for($j = 0; $j < $column; $j++) { if(isset($data[$i + ($j * $rows)])) { echo "<td>".$data[$i + ($j * $rows)]."</td><td><input type='checkbox' name='member' value='".$data[$i + ($j * $rows)]."'></td>\n"; } } echo "</tr>\n"; } echo "</table>\n"; ?> <input type="submit" value='Attendence'> </fieldset> </form> </body> </html> This is my first page, so name='member' suppose to delivery value (person's name) to my second page. This first page DO work in vertical table data perfect that I found website that show me a code. Check this website for example - http://sigmahokies.biz.ht/testarray2.php Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/page/2/#findComment-1514998 Share on other sites More sharing options...
CroNiX Posted June 26, 2015 Share Posted June 26, 2015 echo "<td>".$data[$i + ($j * $rows)]."</td><td><input type='checkbox' name='member' value='".$data[$i + ($j * $rows)]."'></td>\n"; Change name="member[]", with [] after. That's the HTML way to create an array in a form using the same name. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/page/2/#findComment-1515010 Share on other sites More sharing options...
sigmahokies Posted June 26, 2015 Author Share Posted June 26, 2015 I did that before...still not work, but let's see... Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/page/2/#findComment-1515013 Share on other sites More sharing options...
sigmahokies Posted June 26, 2015 Author Share Posted June 26, 2015 Oh FINALLY!!!! it works!!! FINALLY!!! i am going to create 200 name in database! It is EXACTLY what I need to do! Thank you, Cronix and Jazzman1!!! Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/page/2/#findComment-1515014 Share on other sites More sharing options...
sigmahokies Posted June 26, 2015 Author Share Posted June 26, 2015 Jazzman1, your code is working, but it apply to two columns, I need to have many columns, I notice ascending don't work in 1 and 3 or more than 3 columns. I added sort(), but seem it won't recognized this code to make those name stay in order... Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/page/2/#findComment-1515019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.