Jump to content

derrick katungi

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

derrick katungi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. $data[numm0] = array(1,2,3,4,5,6); $data[numm1] = array(1,3,4,5,6); $data[numm2] = array(1,2,3,4,6); $data[numm3] = array(1,2,3,5,6); echo 'its here'. array_sum($data[numm0]).'<br>'; print_r($data); foreach($data as $key=>$value) { echo $key .'has a sum of ' .array_sum($value).'<br>'; } this is the way of doing it because print_r() and array_sum() have specific parameters. for example; print_r() has two parameters of which the second must be boolean....
  2. <?php error_reporting(0); $numm0 = array(1,2,3,4,5,6); $numm1 = array(1,3,4,5,6); $numm2 = array(1,2,3,4,6); $numm3 = array(1,2,3,5,6); for($i = 0;$i < 4;$i++) { print_r($numm.$i); } for($i = 0;$i < 4;$i++) { $w.$i = array_sum($numm.$i); print_r($w.$i); echo "<br>"; } ?> this code just hangs when executed. how can the syntax of the print_r() function and array_sum() function be modified? need help...
  3. use this idea, if your age range(7-8,8-9,9-10,etc) falls between $inn[1] and $outt[1] you get $numm[1] which is between 10 and 16, you get 5.
  4. the syntax is OK, at least on my side. i have realized that i have to come up with a completely new algorithm so those nested loops with arrays are based on the wrong algorithm. going to come up with another...enjoy the weekend
  5. thats true man but i have ever coded in C (borland) and i used to get funny results from $i < $num_rows so i switched to $i <= ($num_rows - 1)..but there's no biggie here, i still have a bigger problem dude.... this is my update so far... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Second Testing</title> <link href="styler.css" rel="stylesheet" type="text/css" /> </head> <body> <?php error_reporting(0); $num_rows = 16; $number1 = 4; $inn = array(7,10,13,16); $outt = array(14,16,21,23); $numm = array(3,5,7,9); $r_time_in = min($inn); for($i = 0; $i <= $num_rows; $i++) { $new_r_timer_in[$i] = $r_time_in; $new_r_timer_out[$i] = $new_r_timer_in[$i] + 1; $r_time_in += 1; } for($y = 0; $y <= $number1; $y++) { for($i = 0; $i <= ($num_rows - 1); $i++) { if(($inn[$y] <= $new_r_timer_in[$i]) || ($outt[$y] <= $new_r_timer_out[$i])) { $numb[$i] = $numm[$y] + $numm[$y - 1]; } else { $numb[$i] = $numm[$y - 1]; } } } for($i = 0; $i <= ($num_rows - 1); $i++) { echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="$r_in[]" value="'.$new_r_timer_in[$i].'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_out[]" value="'.$new_r_timer_out[$i].'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_num[]" value="'.$numb[$i].'" style="width:169px" readonly="readonly" class="text_non_color"/></td>'; } print("</tr>"); ?> </body> </html> i have "un-commented" the section that had the nested loops and arrays and it outputs something that's definitely wrong
  6. in the first for loop, change $i++ to $y++.. it should now output something in the third column as well but its not the correct data..
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Second Testing</title> <link href="styler.css" rel="stylesheet" type="text/css" /> </head> <body> <?php error_reporting(0); $num_rows = 16; $number1 = 4; $inn = array(7,10,13,16); $outt = array(14,16,21,23); $numm = array(3,5,7,9); $r_time_in = min($inn); for($i = 0; $i <= $num_rows; $i++) { $new_r_timer_in[$i] = $r_time_in; $new_r_timer_out[$i] = $new_r_timer_in[$i] + 1; $r_time_in += 1; } // for($y = 0; $y <= $number1; $i++) // { // for($i = 0; $i <= ($num_rows - 1); $i++) // { // if(($inn[$y] <= $new_r_timer_in[$i]) || ($outt[$y] <= $new_r_timer_out[$i])) // { // $numb[$i] = $numm[$i] + $numm[$i - 1]; // } // else // { // $numb[$i] = $numm[$i - 1]; // } // } // } for($i = 0; $i <= ($num_rows - 1); $i++) { echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="$r_in[]" value="'.$new_r_timer_in[$i].'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_out[]" value="'.$new_r_timer_out[$i].'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_num[]" value="'.$numb[$i].'" style="width:169px" readonly="readonly" class="text_non_color"/></td>'; } print("</tr>"); ?> </body> </html> the code above works very well in its current state. three columns are produced but only two have data, the third column is empty. when executed, the code is supposed to check whether a range(7 - is between the first element of array $inn and the first element of array $outt and then add the corresponding number in array $numm to the number in that(7 - range the commented out code is supposed to implement this idea but its not.........help.
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>testing</title> <link href="styler.css" rel="stylesheet" type="text/css" /> </head> <body> <?php error_reporting(0); $lowest_time = date('H:i:s',(strtotime() + (min($inn) * 86400))); $adder = date('H:i:s',(strtotime() + ((min($inn) + 0.0416666666666667) * 86400))); echo '<form id="form1" name="form1" method="post" action="test.php"> <table width="526" border="0"><tr> <td width="169"> <input type="text" name="$r_in[]" value="'.$lowest_time.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_out[]" value="'.$adder.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_num[]" value="'.$number1.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> </tr></table>'; $r_time_in = min($inn); $r_time_out = $r_time_in + 0.0416666666666667; for($i = 0; $i <= 5; $i++) { $r_time_in += 0.0416666666666667; $new_r_timer_in[$i] = $r_time_in; $new_r_timer_out[$i] = $new_r_timer_in[$i] + 0.0416666666666667; } for($i = 0; $i <= 5; $i++) { echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="$r_in[]" value="'.date('H:i:s',(strtotime() + ($new_r_timer_in[$i] * 86400))).'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_out[]" value="'.date('H:i:s',(strtotime() + ($new_r_timer_out[$i] * 86400))).'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_num[]" value="'.$number1.'" style="width:169px" readonly="readonly" class="text_non_color"/></td>'; } $html = '</table></form>'; echo $html; ?> </body> </html> something like this 12:00:00 - 01:00:00 01:00:00 - 02:00:00 02:00:00 - 03:00:00 is produced fro the code above. this was what i was looking for. thanks everyone
  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>testing</title> <link href="styler.css" rel="stylesheet" type="text/css" /> </head> <body> <?php error_reporting(0); $lowest_time = date('H:i:s',(strtotime() + (0.0000000000000000 * 86400))); $adder = date('H:i:s',(strtotime() + (0.0000000000000000 + 0.0416666666666667) * 86400)); echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="$r_in[]" value="'.$lowest_time.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_out[]" value="'.$adder.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> </tr></table>'; for($i = 0; $i <= 5; $i++) { echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="$r_in[]" value="'.date('H:i:s',(strtotime() + (($r_in[$i] + 0.0416666666666667) * 86400))).'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_out[]" value="'.date('H:i:s',(strtotime() + (($r_out[$i] + 0.0416666666666667) * 86400))).'" style="width:169px" readonly="readonly" class="text_non_color"/></td> </tr></table>'; } ?> </body> </html> from above, it should keep on storing data into the arrays. in the for loop, $i starts from 1 coz the index 0 is already used. thats the idea am heading for.
  10. it actually needs a button to post, so you were right before. i want to put an array in the name attribute, name ="$r_in[]". so am still stranded...
  11. $number1 can stay empty. its not relevant at this time.
  12. nop, it did not work Voip03...
  13. thats true with the bitton but it can also work without. my problem is basically with the name attribute. both name="$r_in" and name="'.$r_in.'" have failed. icant echo the variable $r_in.
  14. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>testing</title> <link href="styler.css" rel="stylesheet" type="text/css" /> </head> <body> <?php error_reporting(0); $lowest_time = date('H:i:s',(strtotime() + (0.0000000000000000 * 86400))); $adder = date('H:i:s',(strtotime() + (0.0000000000000000 + 0.0416666666666667) * 86400)); echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="" value="'.$lowest_time.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="" value="'.$adder.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="" value="'.$number1.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> </tr></table>'; for($i = 0; $i <= 5; $i++) { echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="" value="'.date('H:i:s',(strtotime() + (($r_inn + 0.0416666666666667) * 86400))).'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="" value="'.date('H:i:s',(strtotime() + (($r_outt + 0.0416666666666667) * 86400))).'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="" value="'.$number1.'" style="width:169px" readonly="readonly" class="text_non_color"/></td>'; } ?> </body> </html> i dont know what the name= "" attribute should be. i want the output to be something like this. 12:00:00 - 01:00:00 01:00:00 - 02:00:00 02:00:00 - 03:00:00
  15. the code is in a form whose method = "post". i have failed to echo $r_in. i eed help on this. $lowest_time = 30 - 14; $adder = 2*5*9; echo '<table width="526" border="0"><tr> <td width="169"> <input type="text" name="$r_in" value="'.$lowest_time.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> <td width="169"> <input type="text" name="$r_out" value="'.$adder.'" style="width:169px" readonly="readonly" class="text_non_color"/></td> </tr></table>';
×
×
  • 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.