Jump to content

FoxRocks

Members
  • Posts

    45
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

FoxRocks's Achievements

Member

Member (2/5)

0

Reputation

  1. Yes, I do. I guess I should have just ignored it instead of bringing attention to it. My Bad.
  2. To whoever last updated my fiddle, while I'm not a "faggot" as you claim, I'm also not a coward. You might think that updating the fiddle to say such a thing is funny and clever, but in reality it's just pathetic. If you have something to say, just say it and don't be such a juvenile. ~FOX~
  3. Right, I didn't really explain the solution very well. The FOR loop was already looping through each value of the $date array. When I accidentally added the [$i] key to it, it broke that value down further thinking it was mutlidimensional array, when it wasn't. ~FOX~
  4. "basic debugging 101" , ok, I guess my error checking wasn't cutting it? I echo'd out everything you did, I just didn't label which line it was on. It's not that I don't appreciate getting helped in the right direction, or being taught how to troubleshoot instead of just being handed the answer...in fact I prefer that over just getting the answer...however the var_dump() and the "basic debugging 101" ideas didn't produce anything new that my already existing error checking didn't already have. Anyways, I've found the problem. It was a stupid one as I'm sure we all expected. Thanks for the help, I'm sorry if I sound unappreciative with my comment, don't take it personally. ~FOX~ EDIT: I forgot to say what the problem was. I changed $date[$i] to just $date in the insert statement and it worked fine.
  5. Here it is: array (size=1) 0 => string '2013-01-01' (length=10)
  6. Here is a phpfiddle: http://phpfiddle.org/main/code/wz6-afn
  7. OK, here is my form code, all of it, including the $_SESSION's. I've added some echo statements. <?php $_SESSION['tod_fromDate'] = "2013-01-01"; $_SESSION['tod_toDate'] = "2013-01-01"; $fromSTR = $_SESSION['tod_fromDate']; $toSTR = $_SESSION['tod_toDate']; $fromTIME = strtotime($fromSTR); $toTIME = strtotime($toSTR); $_SESSION['emp_id'] = "9078"; $emp_id = $_SESSION['emp_id']; $tod_name = "Taken Days Off"; $tod = 8; ?> <form method="post" action=""> <table cellpadding="4" cellspacing="0" border="1" id="tod_tracking_form"> <tr align="center"> <td colspan="3"><?php echo $tod_name; ?> Tracking Form</td> </tr> <tr align="center"> <td class="bold">Date Taken</td> <td class="bold">Notes</td> <td class="bold">Entered By</td> </tr> <?php for($i = $fromTIME; $i <= $toTIME; $i = strtotime('+1 day', $i)) { echo "for i: " . $i . "<br>";//Error checking $adate = date('Y-m-d',$i); echo "for adate: " . $adate . "<br>";//Error checking $bdate = date('M jS Y',$i); echo "for bdate: " . $bdate . "<br>";//Error checking echo "<tr>"; echo "<td align=\"center\"><input type=\"hidden\" name=\"tod_date[]\" value=\"" . $adate . "\">" . $bdate . "</td>"; echo "<td><textarea name=\"tod_note[]\" style=\"resize:none;\" maxlength=\"255\" cols=\"25\" rows=\"3\"></textarea></td>"; //Change the value below once the admin area has been created. Use the session admin id here. echo "<td align=\"center\"><input type=\"hidden\" name=\"tod_admin\" value=\"10845\">10845</td>"; echo "</tr>"; } ?> <tr align="center"> <td colspan="3"><input type="submit" name="tod_submit" style="width:100px;" value="SUBMIT"></td> </tr> </table> </form> <?php if(isset($_POST['tod_submit'])) { $tod_date = $_POST['tod_date']; $note = $_POST['tod_note']; $admin = $_POST['tod_admin']; $i = 0; foreach($tod_date as $date) { $sql = ("INSERT INTO tod_tracking (Emp_ID, TOD_Date, TOD_Note, TOD_Admin) VALUES ('$emp_id', '$date[$i]', '$note[$i]', '$admin')"); echo "foreach i: " . $i . "<br>";//Error checking echo "foreach date[i]: " . $date[$i] . "<br>";//Error checking // if(!$result_sql = $mysqli->query($sql)) // { // die ("There was a problem inserting the records into the tod_tracking table. mySQLI Error: " . $mysqli->error . ""); // } echo "sql: " . $sql . "<br>";//Error checking $i++; } //unset($_SESSION['tod']); //redirect_to($url); } ?> Now, here is the page source once the code has run: <form method="post" action=""> <table cellpadding="4" cellspacing="0" border="1" id="tod_tracking_form"> <tr align="center"> <td colspan="3">Taken Days Off Tracking Form</td> </tr> <tr align="center"> <td class="bold">Date Taken</td> <td class="bold">Notes</td> <td class="bold">Entered By</td> </tr> for i: 1356998400<br>for adate: 2013-01-01<br>for bdate: Jan 1st 2013<br><tr><td align="center"><input type="hidden" name="tod_date[]" value="2013-01-01">Jan 1st 2013</td><td><textarea name="tod_note[]" style="resize:none;" maxlength="255" cols="25" rows="3"></textarea></td><td align="center"><input type="hidden" name="tod_admin" value="10845">10845</td></tr> <tr align="center"> <td colspan="3"><input type="submit" name="tod_submit" style="width:100px;" value="SUBMIT"></td> </tr> </table> </form> foreach i: 0<br>foreach date[i]: 2<br>sql: INSERT INTO tod_tracking (Emp_ID, TOD_Date, TOD_Note, TOD_Admin) VALUES ('9078', '2', 'Here are the notes', '10845')<br> And finally, here is a screen shot of the form with the echo statements: This makes NO sense to me, I can't believe I'm either missing something obvious, or that I can't get it to work...ugh.
  8. Thank you all for the replies. I should have included what the variable are set to, sorry. <?php $fromSTR = $_SESSION['tod_fromDate']; //Selected through the date picker $toSTR = $_SESSION['tod_toDate']; //Selected through the date picker. This is possibly the same value as $_SESSION['tod_fromDate'] $fromTIME = strtotime($fromSTR); $toTIME = strtotime($toSTR); $emp_id = $_SESSION['emp_id']; //Set from the database ?> I have printed all of these out and they come out as expected: <?php $fromDate = 2013-01-01; $toDate = 2013-01-01; $emp_id = 9078; ?>
  9. Hi there, First, thank you for your interest in my problem, I appreciate your time. I have a small form that is populated with records from a mysql database using php. I have three <input>'s which have the name attribute set to an array in case there is more than one record. The problem I'm having is for some reason the $adate (which is === "2013-01-01") gets broken down into 10 parts of an array. I don't get it, I've used this exact same setup on 5 or 6 other pages and it doesn't do this. Just to be clear, when I echo out $date, it looks like this: $date[$i] = 2 And when I run through it, it looks like this: $date[0] = 2 $date[1] = 0 $date[2] = 1 $date[3] = 3 $date[4] = - $date[5] = 0 $date[6] = 1 $date[7] = - $date[8] = 0 $date[9] = 1 What I'm expecting, and wanting, is this: $date[$i] = 2013-01-01 Here is my form code: <form method="post" action=""> <table cellpadding="4" cellspacing="0" border="1" id="wod_tracking_form"> <tr align="center"> <td colspan="3"><?php echo $wod_name; ?> Tracking Form</td> </tr> <tr align="center"> <td class="bold">Date Worked</td> <td class="bold">Notes</td> <td class="bold">Entered By</td> </tr> <?php for($i = $fromTIME; $i <= $toTIME; $i = strtotime('+1 day', $i)) { $adate = date('Y-m-d',$i); $bdate = date('M jS Y',$i); echo "<tr>"; echo "<td align=\"center\"><input type=\"hidden\" name=\"wod_date[]\" value=\"" . $adate . "\">" . $bdate . "</td>"; echo "<td><textarea name=\"wod_note[]\" style=\"resize:none;\" maxlength=\"255\" cols=\"25\" rows=\"3\"><textarea></td>"; //Change the value below once the admin area has been created. Use the session admin id here. echo "<td align=\"center\"><input type=\"hidden\" name=\"wod_admin\" value=\"10845\">10845</td>"; echo "</tr>"; } ?> <tr align="center"> <td colspan="3"><input type="submit" name="wod_submit" style="width:100px;" value="SUBMIT"></td> </tr> </table> </form> Here is my code for inserting it into the database: <?php if(isset($_POST['wod_submit'])) { $wod_date = $_POST['wod_date']; $note = $_POST['wod_note']; $admin = $_POST['wod_admin']; $i = 0; foreach($wod_date as $date) { $sql = ("INSERT INTO wod_tracking (Emp_ID, WOD_Date, WOD_Note, WOD_Admin) VALUES ('$emp_id', '$date[$i]', '$note[$i]', '$admin')"); if(!$result_sql = $mysqli->query($sql)) { die ("There was a problem inserting the records into the wod_tracking table. mySQLI Error: " . $mysqli->error . ""); } $i++; } die; //unset($_SESSION['wod']); //redirect_to($url); } ?> I don't know if this is because it's in a date format, or what, but it's causing me a lot of confusion, I would really appreciate some help on this one. Cheers! ~FOX~
  10. Yes! I totally get it now! Finally...the world makes sense again Thank you so much for your help! ~FOX~
  11. In case you're in the mood, I do have one other question. How would it work if I had a table that was reference by the "employee" table (not previously mentioned in my post) and I needed to get that info up to the "schedule" table? For example, the employees might have a drivers license of a certain class, so I've got a table called "license" that is linked to the "employee" table. The columns are called "Lic_ID" in both the "employee" table and the "license" table. Does that make sense? Hopefully. I want to be able to show the "license" class of the "employee" on the "schedule". Cheers, ~FOX~
  12. Funny, I was just coming back to let you know I found some answers and I see you've already replied! I was able to figure out the answer to if $row['Area_Name'] would work, and it does...brilliant! I hadn't found the answer to the other part about the alias, I'll have to do some more reading obviously, but thank you for that. In short, you were a huge help and I really appreciate it. Thank you so much!! ~FOX~
  13. Hi gristoi, Thank you for the reply, and for the example. So with the example you gave, would I call out the parameters as normal? Meaning, would $row['Area_Name'] work? Also, I don't really understand everything you wrote, specifically, what is "schedule s" and "area a" all about? While I wait for a reply, I'll go and read up some more on JOINS to see if I can answer my own question Cheers! ~FOX~
  14. Good day, First, thank you for taking the time to look at my post, I appreciate it and I will try not to waste your time. I have recently been challenged to make an employee management database. I have some experience using mySQL and PHP and consider myself "comfortable" with how it works. This is however the first time I've used a relational db for anything. I am having a hard time getting my head around how it's all going to come together in the end, so I'm hoping that you can fill in some blanks for me and help me see the light, so to speak. Right now I have my tables set up and the primary and foreign keys set up in a database. This is the "schedule" : And in the interest of keeping the post short, I'll include just on of the referenced tables, that is "area" : So as you can see I've referenced the Area_ID in the schedule table and that is because I want to be able to assign an employee to a work area in the shop. Here is a screen shot of one record in the schedule table: So as I mentioned I am having trouble seeing how it all comes together. Specifically I am having trouble seeing how "Area ID - 6" is going to translate into "Area_Name - Paint Shop" (record #6 = Paint Shop). Normally when I query the db for the information, I would do something like: $result = mysql_query("SELECT * FROM schedule"); And then from there I would usually do something like: while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Emp_ID'] . "</td>"; echo "<td>" . $row['Cal_Date'] . "</td>"; echo "<td>" . $row['Area_ID'] . "</td>"; echo "<td>" . $row['Shift_ID'] . "</td>"; echo "<td>" . $row['Stat_ID'] . "</td>"; echo "</tr>"; } But in this case instead of "Paint Shop" I would, obviously get "6". This is my brick wall that I can't seem to get my head around. I have been reading about JOINS and still, for some reason, I just can't put two and two together. I would really appreciate any help and or constructive criticism you can give. Cheers, ~FOX~
×
×
  • 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.