Jump to content

jomak73

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jomak73's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yea i think that'll work great! Thankss
  2. This is probably a really simple question. Is it possible to initialize x amount of variables. Like someone enters 10 into an input box and it makes 10 variables called variable1, variable2, variable3, etc. How would you name them? $variable + num = 0; ? Thanks!
  3. Ooook I just started learning php and mysql about a week ago, so I dunno if this code is like super messed up.. but here it is. function saveForm() { global $suname, $task11, $task12, $task13, $task21, $task22, $task23, $task31, $task32, $task33, $task41, $task42, $task43, $task51, $task52, $task53, $sproject1, $sproject2, $sproject3, $sproject4, $sproject5, $sweekending; $numrows=15; $irow=1; $ncnt=0; while ($irow <= 3) { trim('saveDay($suname, $sproject1, "mon", $task1'+$irow+', 1, $ncnt++, $irow);'); // I dunno if trim is right here. I needed something that would let me have the 4th variable change on each loop trim('saveDay($suname, $sproject1, "tue", $task1'+$irow+', 2, $ncnt++, $irow);'); trim('saveDay($suname, $sproject1, "wed", $task1'+$irow+', 3, $ncnt++, $irow);'); trim('saveDay($suname, $sproject1, "thu", $task1'+$irow+', 4, $ncnt++, $irow);'); trim('saveDay($suname, $sproject1, "fri", $task1'+$irow+', 5, $ncnt++, $irow);'); trim('saveDay($suname, $sproject1, "sat", $task1'+$irow+', 6, $ncnt++, $irow);'); trim('saveDay($suname, $sproject1, "sun", $task1'+$irow+', 7, $ncnt++, $irow);'); ++$irow; } while ($irow <= 6) { trim('saveDay($suname, $sproject2, "mon", $task2'+$irow-3+', 1, $ncnt++, $irow);'); trim('saveDay($suname, $sproject2, "tue", $task2'+$irow-3+', 2, $ncnt++, $irow);'); trim('saveDay($suname, $sproject2, "wed", $task2'+$irow-3+', 3, $ncnt++, $irow);'); trim('saveDay($suname, $sproject2, "thu", $task2'+$irow-3+', 4, $ncnt++, $irow);'); trim('saveDay($suname, $sproject2, "fri", $task2'+$irow-3+', 5, $ncnt++, $irow);'); trim('saveDay($suname, $sproject2, "sat", $task2'+$irow-3+', 6, $ncnt++, $irow);'); trim('saveDay($suname, $sproject2, "sun", $task2'+$irow-3+', 7, $ncnt++, $irow);'); ++$irow; } while ($irow <= 9) { trim('saveDay($suname, $sproject3, "mon", $task3'+$irow-6+', 1, $ncnt++, $irow);'); trim('saveDay($suname, $sproject3, "tue", $task3'+$irow-6+', 2, $ncnt++, $irow);'); trim('saveDay($suname, $sproject3, "wed", $task3'+$irow-6+', 3, $ncnt++, $irow);'); trim('saveDay($suname, $sproject3, "thu", $task3'+$irow-6+', 4, $ncnt++, $irow);'); trim('saveDay($suname, $sproject3, "fri", $task3'+$irow-6+', 5, $ncnt++, $irow);'); trim('saveDay($suname, $sproject3, "sat", $task3'+$irow-6+', 6, $ncnt++, $irow);'); trim('saveDay($suname, $sproject3, "sun", $task3'+$irow-6+', 7, $ncnt++, $irow);'); ++$irow; } while ($irow <= 12) { trim('saveDay($suname, $sproject4, "mon", $task4'+$irow-9+', 1, $ncnt++, $irow);'); trim('saveDay($suname, $sproject4, "tue", $task4'+$irow-9+', 2, $ncnt++, $irow);'); trim('saveDay($suname, $sproject4, "wed", $task4'+$irow-9+', 3, $ncnt++, $irow);'); trim('saveDay($suname, $sproject4, "thu", $task4'+$irow-9+', 4, $ncnt++, $irow);'); trim('saveDay($suname, $sproject4, "fri", $task4'+$irow-9+', 5, $ncnt++, $irow);'); trim('saveDay($suname, $sproject4, "sat", $task4'+$irow-9+', 6, $ncnt++, $irow);'); trim('saveDay($suname, $sproject4, "sun", $task4'+$irow-9+', 7, $ncnt++, $irow);'); ++$irow; } while ($irow <= 15) { trim('saveDay($suname, $sproject5, "mon", $task5'+$irow-12+', 1, $ncnt++, $irow);'); trim('saveDay($suname, $sproject5, "tue", $task5'+$irow-12+', 2, $ncnt++, $irow);'); trim('saveDay($suname, $sproject5, "wed", $task5'+$irow-12+', 3, $ncnt++, $irow);'); trim('saveDay($suname, $sproject5, "thu", $task5'+$irow-12+', 4, $ncnt++, $irow);'); trim('saveDay($suname, $sproject5, "fri", $task5'+$irow-12+', 5, $ncnt++, $irow);'); trim('saveDay($suname, $sproject5, "sat", $task5'+$irow-12+', 6, $ncnt++, $irow);'); trim('saveDay($suname, $sproject5, "sun", $task5'+$irow-12+', 7, $ncnt++, $irow);'); ++$irow; } } The point is to take information that the user has entered (all the global variables) and save them in a database. Buuut.. it doesnt work. The saveDay function is defined as: function saveDay($suname, $sproject, $sday, $itask, $iday, $ncnt, $irow) { $sdate = $_REQUEST[$sday]; $sdate2 = date("Y-m-d",strtotime($sdate)); mysql_query("DELETE FROM Time WHERE date='$sdate2' AND username='$suname' AND project_id='$sproject' AND task_id=$itask"); $shours = trim($_REQUEST["hrs" . $irow . "-" . $iday]); // <--- takes the number entered into a cell on row(1-15) and day of the week(1-7) of a table if ( strlen($shours)>0 && doubleval($shours)>0 ) { $sbhours = trim($_REQUEST["bhrs" . $irow . "-" . $iday]); // takes another number entered into a cell on row(1-15) and day of the week if ( strlen($sbhours)==0 ) $sbhours="0"; // if nothing was entered, make it 0 $scomment = rawurldecode($_REQUEST["comment" . $irow . "-" . $iday]); // Make sure the comment raw text // gets a comment entered into a cell on row(1-15) and day of the week $query = "INSERT INTO Time VALUES (0, '$sdate2', '$suname', '$sproject', $itask, $shours, '$scomment', $sbhours)"; mysql_query($query); } } Sorry if it's hard to understand. A solution would be greaaatly appreciated. THANKS!
×
×
  • 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.