Jump to content

amalafrida

Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by amalafrida

  1. All of the foregoing 'impolitesse' to the contrary notwithstanding, the non-obvious (at least to me) solution appears to be the code I've posted below. Any suggestions or advice will be greatly appreciated. given this Array: ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 42 [5] => 42 [6] => 42 [7] => 42 [8] => 36 [9] => 36 [10] => 0 [11] => 36 [12] => 36 [13] => 36 [14] => 36 [15] => 36 [16] => 42 [17] => 42 [18] => 42 [19] => 42 [20] => 42 [21] => 42 [22] => 42 [23] => 0 ) how to get to this description of the array: index 0 to index 4 = 0 index 4 to index 8 = 42 index 8 to index 16 = 36 index 16 to index 23 = 42 index 23 = 0 $startIndex = 0; $endIndex = 0; $lastVal = $val[0]; for($i=1; $i<25; $i++) { if ($val[$i] == $lastVal) { $endIndex = $i; } else { if($endIndex==23) $term="00:00"; else $term=($endIndex+1) . ":00"; if($lastVal!=0) $report.=$lastVal . "<br>" . ($startIndex) . ":00 to: " . $term . "<br>"; $startIndex = $i; $endIndex = $i; $lastVal = $val[$i]; } }
  2. In the interest of brevity, I did not post the code that generated the array. That struck me as the courteous approach, rather than burdening the list with unnecessary verbiage. I fail to understand your assumption that this is an "assignment". And I certainly do not appreciate your censorious responses. Let me repeat: I did not post an assignment and say that I don't know what to do. I posed a problem I'd been working with for quite some time and asked for some assistance, advice. A post to "stack overflow", phrased exactly as the post that began this thread, elicited a lucid and kind respose within 15 min. ... not a full solution, but advice, respectful and patient, sufficient to permit me to solve my "non-assignment". I will no doubt work with that group in the future or at least await responses on this list from members other than yourself. Would it be incendiary of me to suggest that you look into "charm" lessons?
  3. Well, thanks, advanced member, I guess. However, I did not believe myself to be asking for homework help. Only perhaps a bit of lucid advice. Your reply falls remarkably short on lucidity, a bit too far on moralizing ... (don't ask us to do your homework, don't ask us to write your code for you, the answer is obvious ... do it yourself). Just a bit of advice beyond the obvious lies at the heart of my request. Yes, "foreach/for" strikes me too as altogether obvious, but the part between the braces not so obvious for a "non-freak" "non-guru" type. Will keep casting about, however, for further suggestions.
  4. what sort of php array enumeration must I use to get from this: Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 42 [5] => 42 [6] => 42 [7] => 42 [8] => 36 [9] => 36 [10] => 0 [11] => 36 [12] => 36 [13] => 36 [14] => 36 [15] => 36 [16] => 42 [17] => 42 [18] => 42 [19] => 42 [20] => 42 [21] => 42 [22] => 42 [23] => 0 ) to this description of the array: index 0 to index 4 = 0 index 4 to index 8 = 42 index 8 to index 16 = 36 index 16 to index 23 = 42 index 23 = 0 my head is swirling with conditionals and loops ... getting dizzy ... can't crack it. thanks in advance for any assistance.
  5. still foggy. are you then suggesting that the table be structured as follows: each row should contain 2 cells ... 1) a timestamp cell 2) one cell containing 24 text boxes? thanks for your patience.
  6. I don't understand your "timestamp/column" comment. The first cell of each row carries a timestamp. a typical row resembles the following: <td> <input type='text' name='date[1345438800]' value='Mon-20-Aug' /></td> <td> <input type='text' name='datacell[0]' value='Z' /> </td> .... <td> <input type='text' name='datacell[23]' value='A' /> </td> I'm looping through and picking up each day's sequence of 24 values and placing them into an array ... key=timestamp value=24 letter codes ... then to the database with it ... user is free to modify any of the available text boxes.
  7. should have specified: each POST element looks like this: <td> <input type='text' name='datacell[5]' value='I' /></td>
  8. Trying to POST values from a table ... each table cell represents 1 hour of each day for 6 months ... total approx. 4000 the cells are named datacell[0] ... datacell[4000] however, when i foreach($_POST['datacell'] as $key=>$val) { $codes.=$val; } echo strlen($codes); strlen is only 1001 ... same if I push them into an array any suggestions? beginning to think I have reached an unwieldy limit here ... break the calendar up ... present only one month at a time?
  9. Yes, a letter can repeat. Am interested in elaboration of this observation by Jesirose: "While I don't agree with the reasoning behind this, here's a function." And yes, just counting characters. Thanks for all the help.
  10. what would be the best way to generate this string 7a3b7c4d10e from this string aaaaaaabbbcccccccddddeeeeeeeeee I have many 10,000s of strings of this sort, 168 characters each to store in database. attempting to minimize storage space. ??? thanks in advance
  11. is this the proper forum to pose a pear install question?
  12. yes! that is precisely what I was looking for. saves me two trips to the database and much unnecessary parsing. once again, many thanks.
  13. I have 5 items in the select/combo box when I _POST that item, I am returned the text contained in the box. BUT, can I know WHICH of the 5 items in the combo box it is? i.e. can I get its index number? ............. ok, yes. thanks. I feared I was skirting that treacherous line betwixt the 2. thanks for the help. you folks are invariably straight up, spot on, not to mention accurate.
  14. $_POST['select'] permits me access to the selected value of my combo box named 'select'. are any other attributes of the box accessible? in particular, index # ... etc.? thanks in advance for any light you might shed on the topic.
  15. <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post"> <input type="submit" name="submit" value="Refresh" /> </form> the above works fine for a refresh button ... but does not if I replace <? with <php?
  16. yes, yes. i think the approach was perfect. i'd much rather learn to handle/explore/diagnose than simply have the answer handed to me. knowing that first step ... looking at php.ini and phpinfo() were two priceless tips. of course, I'll be back for further info, but before I do, I'll certainly have a look at error reports ... and phpinfo() readout. once again, thanks for the assistance/solution/guidance. a.
  17. wow! snapped it right into line. I don't really get that final <?php ?> ... but it works and I'll note it. thanks to everyone for working me through this. pleasant to have gotten the immediate problem solved, but, perhaps more delightful, was to watch the diagnostic process, especially the phpinfo() bit. once again, many thanks to everyone.
  18. phpinfo() reports: Loaded Configuration File /etc/php5/apache2/php.ini Scan this dir for additional .ini files /etc/php5/apache2/conf.d changed php.ini to: Default Value: On restarted apache reloaded form_fill.php received error message: Parse error: syntax error, unexpected '<' in formfill.php on line 9 but I don't see an error at line 9 ... code follows form_fill.php follows: <html> <body> <?php $hours="akj"; $hours_array = str_split($hours); foreach($hours_array as $value) { <form> //line 9 <input name="lname" type="text" value="<?php echo htmlspecialchars( $value); ?>" /> </form> } ?> </body> </html>
  19. went to /etc/php5/apache2/ edited php.ini instead of /etc/php5/cli/php.ini set: display_errors = On error_reporting = -1 apache2 restart phpinfo() reports: display_errors = off error_reporting = 22527
  20. display_errors reports: Off ... for both local and master error_reporting reports: 22527 ... for both local and master
  21. my /etc/php5/cli/php.ini file shows: ; error_reporting : Default Value: E_ALL & ~E_NOTICE ; Development Value: E_ALL | E_STRICT ; Production Value: E_ALL & ~E_DEPRECATED error_reporting = -1 ; display_errors ; Default Value: On ; Development Value: On ; Production Value: Off display_errors = On restarted apache still just a blank screen when I call form_fill.php view source code ... nothing.
  22. Thanks for the response, requinix. However, I'm still not clear on this. Here's the code. When I call form_fill.php ... just a blank screen. <html> <body> <?php $hours="akj"; $hours_array = str_split($hours); foreach($hours_array as $value) { <form> <input name="lname" type="text" value="<?php echo htmlspecialchars( $value); ?>" /> </form> } ?> </body> </html>
  23. how do I populate the textbox values in form.html? Thanks in advance for any help you might offer. //formfill.php <?php $hours="akj"; //split string characters to array $hours_array = str_split($hours); //iterate through the characters in the array foreach($hours_array as $char) { echo($char."<br />"); //somehow populate text boxes in form.html } ?> //form.html <html> <body> <form> <table> <tr> <td><input type="text" name="hour[0]" value="" /></td> <td><input type="text" name="hour[1]" value="" /></td> <td><input type="text" name="hour[2]" value="" /></td> </tr> </table> </form> </body> </html>
×
×
  • 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.