Jump to content

sigmahokies

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by sigmahokies

  1. Jazzman1, Do you want to see my update script? let me know, I will glad to post my updated script in here.
  2. Jazzman1, you want to see my update script in php? let me know, I will post my updated script in php in here...
  3. Oh, I didn't realized there are two : on line 13 and 16, then I changed them to : but still get error in array chunk, it said, Warning: array_chunk() expects parameter 1 to be array, string given in on line 11 Warning: Invalid argument supplied for foreach() in on line 11 1 are attending this meeting tonight. 11 line - foreach (array_chunk($data, 2) as $row): (13 line on jazzman1's comment above)
  4. Cronix, Oops! I changed from ; to : on this line, my habit, heh. Still get error message, it said "Parse error: syntax error, unexpected ':', expecting ',' or ';' in on line 18"
  5. Hi Jazzman1 i followed exactly your code, seem it doesn't work...it gets "parse error, syntax error, unexpect 'endforeach' (T_ENDFOREACH) in" on 20 line. it is 18 line in your line in comment above of here.
  6. Jennifer, All right, there will be two pages code First page code: <!doctype html> <html> <head> <title>Test array with columns</title> </head> <body> <form action="testarray3.php" method="GET"> <fieldset> <?php $column = 5; $Garydb = mysqli_connect(xxxx','xxxx',xxxx') or die("Could not connect to database."); mysqli_select_db($Garydb, 'xxxx'); $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> Second Page (next page) Code: <!doctype html> <html> <head> <title>Test array attendence</title> </head> <body> <table border="1"> <?php $columns = 2; $count = 0; if(isset($_GET['member'])) { $display = ceil($_GET['member']); $rows = ceil($display/$columns); while ($row = array($rows)) { $data['Name'] = $row; } for($i = 0; $i < $rows; $i++) { echo "<tr>"; for($j = 0; $j < $columns; $j++) { if(isset($data[$i + ($j * $row)])) { echo "<td>".$data[$i + ($j * $row)]."</td>"; $count = $count+1; } } echo "</tr>"; } }else{ echo "Fail to get data from previous"; } ?> </table> <table><tr><td><?php echo $count." are attending this meeting tonight." ?></td></tr></table> </body> </html> Second pagesuppose collect data from first page. I'm trying to collect data that been checked on first page, then transfer data to second page. It works with ONE column. But I am trying to create the vertical data instead of row data, vertical data is working on first page, but not work on second page. I think "$data[$i + ($j * $row)]" is not necessary but I'm not sure. I am not professional in PHP yet, but I am learning PHP, I hope I will master PHP in one or two year later. PHP is not easy to understand...Thank you for patient with me. Gary
  7. jennifer lawerence I am not using database to make display, I am using GET and POST to display the data. in previous page,I am using database to display because it shows ALL names on display, in next page, I use GET and POST to collect data name that who "show up" for different reasons. For example, there will be meeting in the club, then president request someone to check any member who come in for meeting, then checklist is complete, then click on submit to next page website, then officer can see list of member who showed up at meeting this time, because not all members will show up at meeting. That is what I am trying to create this website. I am still learning PHP.
  8. You want to see my code? there is still see post my code in other thread, called "what is "Fatal error: Unsupported operand types in" mean". Let me know if you can't find this thread, i will post my code in here...
  9. Cronix, I don't know why it ran out of memory, but strange is previous page is work but next page is not work, but yet program is nearly same as previous page. in few weeks ago, i put thread to hope someone will help me to do table vertical cell data that from GET and POST, several people answer in comment, so I tried to fix by learn from those comment, then page went into error showing those quote about memory is not allowed. Previous page, it works fine, then next page, message error just show up.
  10. Hi everyone I get error message from website - "Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 36 bytes) in" what does it mean? Do I have increase of memory in php.ini? Please let me know Thank you, Gary
  11. Hi Barand, If I change to 6, I'm sure it will apply the up to 6 checkboxes, suppose if i have 200 people in database, I have to set it up as 200 as well? About row, if I set 3, will it be 3 row, then infinite columns?I'm not sure what do you mean about row. That $display is coming from GET, seem it lost data from GET? Also, I put "[]", too (name='member[]') on my script...
  12. Barand, I tried that, still not working, website is still blank as white screen
  13. Darkfreaks, seem your fixed is still not work...I followed your fixed code exactly, just no showing error, just blank...I think I better show you all full code, two pages, because it is about GET and POST, so you can understand very clearly... Here my first page: <!doctype html> <html> <head> <title>Test array with columns</title> </head> <body> <form action="testarray3.php" method="GET"> <--this is set up for second page, see code after this code. <fieldset> <?php $column = 2; $Garydb = mysqli_connect('xxxxxx','xxxxxx','xxxxxx') or die("Could not connect to database."); mysqli_select_db($Garydb, 'xxxxxxx'); $sql = "SELECT CONCAT(FirstName,' ',LastName) AS Name FROM Members ORDER BY LastName ASC"; <-- That is how I merge two columns into one column. $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"; <-- "member" is a transfer data from this page to other page. } } echo "</tr>\n"; } echo "</table>\n"; ?> <input type="submit" value='Attendence'> </fieldset> </form> </body> </html> Now, This is a second page that set up with GET from previous page: <!doctype html> <html> <head> <title>Test array attendence</title> </head> <body> <table> <?php $columns = 2; $count = 0; if(isset($_GET['member'])) { $display = ceil(count($_GET['member'])); $row = ($display/$columns); while ($row = $display) { $data['Name'] = $row; <-- I type "Name" because I made a merge from two columns into one column - "SELECT (FirstName,' ',LastName) AS Name from Members" } echo "<table border='1'>"; for($i = 0; $i < $rows; $i++) { echo "<tr>"; for($j = 0; $j < $columns; $j++) { if(isset($data[$i + ($j * $row)])) { echo "<td>".$data[$i + ($j * $row)]."</td>"; $count = $count+1; } } echo "</tr>"; } } ?> </table> <table><tr><td><?php echo $count." are attending this meeting tonight." ?></td></tr></table> </body> </html> Seem website is blank, no display the record...
  14. Hi everyone, I hope cyberRobot or Guru is reading this thread. I am trying to create a vertical table data in php from method of GET and POST. Is it possible? I succeed created the vertical table data from database (MySQL). I created the vertical table data on php that inside the form thathas method of GET or POST, that should allow any value in php go to another page by method of GET, but seem it doesn't work. Maybe I miss something in code? Help will be very appreciate. I am still learning, ready to get in interaction in php. Here my code: <!doctype html> <html> <head> <title>Test array attendence</title> </head> <body> <table> <?php $columns = 2; if(isset($_GET['member'])) { $display = $_GET['member']; $num_row = $display; $rows = ceil($num_row / $columns); <-- It is causing an error in code, line 14. while ($row = $display) { $data[] = $row; } echo "<table border='1'>"; for($i = 0; $i < $rows; $i++) { echo "<tr>"; for($j = 0; $j < $columns; $j++) { if(isset($data[$i + ($j * $row)])) { echo "<td>".$data[$i + ($j * $row)]."</td>"; $count = $count+1; } } echo "</tr>"; } } ?> </table> <table><tr><td><?php echo $count." are attending this meeting tonight." ?></td></tr></table> </body> </html> I get an error message - Fatal error: Unsupported operand types in /srv/disk10/1141650/www/sigmahokies.biz.ht/testarray3.php on line 14
  15. Hi cyberRobot, Never mind about above comment, I got it! just add $data[$i + ($j * $rows)] in value! it all takes in! Right now, i am testing to use $_GET and $_POST...
  16. Hi cyberRobot, very close, but web address show "Array=Array&Array=Array&Array=Array&Array=Array". I need something to show "Gary=Taylor&(first name)=(last name)&(first name)=(last name)&... which allow transfer any value to other page or display in below of array on top of screen.
  17. Hi Fastsol, I did that...seem value didn't set up with database. here my full code in php. Bold words means it needs to be fix. 1 <!doctype html> 2 <html> 3 <head> 4 <title>Test array with columns</title> 5 </head> 6 <body> 7 <form action="testarray3.php" method="GET"> 8< fieldset> 9 <?php 10 $column = 2; 11 $Garydb = mysqli_connect('xxxx','xxxx','xxxx') or die("Could not connect to database."); 12 mysqli_select_db($Garydb, 'xxxx'); 13 $sql = "SELECT CONCAT(FirstName,' ',LastName) AS Name FROM Members ORDER BY LastName ASC"; 14 $result = mysqli_query($Garydb, $sql); 15 $num_rows = mysqli_num_rows($result); 16 $rows = ceil($num_rows / $column); 17 while ($row = mysqli_fetch_array($result)) { 18 $data[] = $row['Name']; 19 } 20 echo "<table border='1'>\n"; 21 for($i = 0; $i < $rows; $i++) { 22 echo "<tr>\n"; 23 for($j = 0; $j < $column; $j++) { 24 if(isset($data[$i + ($j * $rows)])) { 25 echo "<td>".$data[$i + ($j * $rows)]."</td><td><input type='checkbox' name='".$result['Name']."' value='".$result['Name']."'></td>\n"; 26 } 27 } 28 echo "</tr>\n"; 29 } 30 echo "</table>\n"; 31 ?> 32 <input type="submit" value='Attendence'> 33 </fieldset> 34 </form> 35 </body> 36 </html> I know #25 is wrong, I just can't figure how to put data can display name in checkbox itself. I need to have name from database that inside checkbox, so value can transfer the name into another page.
  18. I succeed to create the vertical data, but I just add checkbox in data table in PHP. I know how to set up the value in checkbox, but i can't figure how to put name and value that from database. for example, when you can see name list in columns, you click checkbox that which has name that selected data from database. here example in code: I can get value from outside of php in html: <input type="checkbox" name="???" value="<?php echo $data['Name'] ?>"> But I can't figure to set up the value that inside php: echo "<tr><td><input type="checkbox" name="???" value=?></td></tr>"; my point is I can use echo to print, but echo is used already, php cannot take two name code in same time, same line number. Can you help? If you want to see my full code in php, Let me know...I will put my code in next comment in this thread. Thank you so much! Gary Taylor
  19. Hi Guru, your code is working, but it is horizon data. I can take horizon data, but I prefer vertical data. If there is possible, Let me know. Thanks, Gary
  20. Oh sorry, I forget about my first thread about while and foreach loop...I asked administrator to remove this thread, Thank you for remind me...
  21. Hi everyone, I am still learning PHP, I am getting better a little, but i am still struggle with while and foreach loop to create few columns. I create one column with while or foreach, but I couldn't figure to create few columns intsead of one long column. Can you help me or make any suggest? Thank you so much
  22. Hi everyone, I am still learning to do PHP, please be patient with me. Thank you so much! I am trying to understand how "while loop" work in PHP, or do you recommend me use foreach, for, or do for array list from MySQL database? my Code in PHP: <!doctype html> <html> <head> <title>Test foreach columns</title> <link href="default.css" rel="stylesheet" type="text/css"> </head> <body> <?php $Garydb = mysqli_connect("XXXXXX","XXXXXX","XXXXXX") or die("Could not connect MySQL Database"); mysqli_select_db($Garydb, "XXXXXX") or die("Could not find Database"); $sql = "SELECT * FROM XXXXXX"; $display = mysqli_query($Garydb, $sql); while($key = mysqli_fetch_array($display)) { echo "<table><tr><td>".$key."</td><td>".$key."</td></tr></table>"; } ?> </body> </html> seem display on website showing "Array Array" 12 row and 2 columns, what I did do wrong?
  23. ginerjm and psycho, ginerjm, All right, my apology if I don't make you understand. my purpose to ask anyone to see if anyone know how to do code in array into few columns, I can do one column. I am trying to have start with top, then down till 10th row, then go to other column with start with top, then go on till 10th row, continue. But I can increase number of row in column if necessary because I will have almost 200 names on database that I don't want to have their name in one column that can make long column on website, so I will like to have 4 or 5 columns to make less long column on website. Do you follow me? If not, my apology because my writing in grammar in English is my second language because I am Deaf, ASL is my first language as usual. Thank you for be patient with me. Psycho, I am still learning, I have been research around about PHP language, there are some I don't understand how it works, example - =>, =<, $i++, \n, %s, %n, \s...I haven't understand complete, but I am still progress to understand them.
  24. Hi everyone, I am still learning to write the code in PHP, it is not easy. I am learning how to use foreach and while array, but I haven't figured how to create the two or more columns, only I can do one column. Soon, I will have larger database coming in, I need to learn how to create few columns, instead of one column. Can anyone help me? not following in row, I rather to follow by columns. Thanks, Gary
  25. QuickOld Car, your code is working, stopping taking blank data when I submitted, thank you! but there is small problem - reload is still taking a blank data in textfield with $_GET because it will stay in textfield when it is reload page, then database will take this data in. So, I change to $_POST... Any advice?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.