Jump to content

gearsgod

Members
  • Posts

    16
  • Joined

  • Last visited

About gearsgod

  • Birthday 01/04/1990

Profile Information

  • Gender
    Male
  • Location
    Washington

Contact Methods

  • Yahoo
    name_hidden_forever

gearsgod's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi I just cant in over a week figure out how I would go about setting up this work time sheet, that displays my employees work times and find any conflicting work hours. But man I have been stumped on getting this code to work! Could anyone fix, or even better teach me a much better way to acomplish this? function time_sheet_day($DB){ $manager_id = $_SESSION['man_id']; $today = date('l'); $year = date('Y'); $ddate = @date(); $date = new DateTime($ddate); $week = $date->format("W"); $page = "<table><tbody><tr><th>ID</th><th>Crew</th><th>Position</th><th>Start Time</th><th>End Time</th></tr>"; $time_sheet_db = $DB->query("SELECT {$today},member_id FROM calendar WHERE manager_id = {$manager_id} AND Week = {$week} AND Year = {$year}"); $time_sheet = []; while($time = $time_sheet_db->fetcharray(SQLITE3_ASSOC)){ $hours = explode('-', $time[$today]); $time_sheet[] = array($time['member_id'], $hours[0], $hours[1]); } $member_info = []; $time_check = $time_sheet; $conflicts = []; $rater = 0; foreach($time_check as $checker){ if($checker[0] == $time_check[$rater][0]){ $rater = $rater + 1; continue; } if($checker[1] == $time_check[$rater][1]){ $conflicts[] = array($checker[0], $time_check[$rater][0], $checker[1]); } $rater = $rater + 1; } foreach($time_sheet as $member){ $member_info_db = $DB->query("SELECT username,crew,postion FROM Members WHERE ID = {$member[0]}"); $member_info = $member_info_db->fetcharray(SQLITE3_ASSOC); $found_conflict=array_find($conflicts, $member[0]); print_r($found_conflict); if($found_conflict == False){ $page .= "<tr><td>{$member_info['username']}</td><td>{$member_info['crew']}</td><td>{$member_info['postion']}</td><td>{$member[1]}</td><td>{$member[2]}</td></tr>"; } else { $page .= "<tr style='background-color:#FF0000'><td>{$member_info['username']}</td><td>{$member_info['crew']}</td><td>{$member_info['postion']}</td><td>{$member[1]}</td><td>{$member[2]}</td></tr>"; } } $page .= '</tbody></table>'; echo ($page); } function array_find($parents, $searched) { if (empty($searched) || empty($parents)) { return false; } foreach ($parents as $key => $value) { $exists = true; foreach ($searched as $skey => $svalue) { $exists = ($exists && IsSet($parents[$key][$skey]) && $parents[$key][$skey] == $svalue); } if($exists){ return $key; } } return false; }
  2. The errors are gone, but now it does not find conflicts in an array and point out the key for it :/ example: Array ( [0] => Array ( [0] => 12 [1] => 12 [2] => 1pm ) [1] => Array ( [0] => 13 [1] => 13 [2] => 1pm ) ) as you can see, they both are set at 1pm, it needs to return a true, but my script thinks its still false
  3. I keep getting these errors, running php 5.4; Notice: Undefined variable: value in C:\xampp\htdocs\BK\functions.php on line 133 Warning: Creating default object from empty value in C:\xampp\htdocs\BK\functions.php on line 133 Fatal error: Cannot access empty property in C:\xampp\htdocs\BK\functions.php on line 133 and heres my code; 128 function array_find($parents, $searched) { 129 if (empty($searched) || empty($parents)) { 130 return false; 131 } 132 133 foreach ($parents as $key -> $value) { 134 $exists = true; 135 foreach ($searched as $skey -> $svalue) { 136 $exists = ($exists && IsSet($parents[$key][$skey]) && $parents[$key][$skey] == $svalue); 137 } 138 if($exists){ return $key; } 139 } 140 141 return false; 142 }
  4. Good point, you wouldn't happen to have a handy script for that? if not I guess I will try a little google + my imagination
  5. Ah here we go, I had to add this into the .htaccess file AddCharset UTF-8 .html .php now it displays the chars rightly.
  6. hmmm this is interesting, when I tried it on a local copy it gets inserted into the database fine, but when u pull it out and display it, well I think you know what happens...
  7. try it, I made it so it should support everything.
  8. I have done a lot of changing and I added some new things. adding rows/tables and stuff will prob come later but I fixed the updating when its not needed and did some tweaking. if you want me to push what I have changed now as an update I can, but I feel like I need to add and change a few more things before I push an update to everyone.
  9. Ah that beast.... That's actually Binary data. I haven't got around to finding a way to display 'Binary data here' instead of what you see.
  10. What do you mean that encoding is all messed up? I used base64 to encode all the data first as to not a have a problem during transport and to have some data recovery if some packets get lost more often then not and to avoid some problems I was having early on. The demo is the fully working thing. but I'm getting a lot of bugs and errors. firebug says everything is running fine on my firefox. can you post some screen shots or error codes? Oh and are you using PHP5.3.X and cURL7+? You don't seem to be detecting when a database is empty or not, you just spit out the fields. There's no button to add more data, no button to delete, etc.... I was just getting around to that. just needed to know some details about it now. it's guys like you I was looking forward to and more down the post to tell me what I needed to add/ improve that makes me breath easier. I think having the database first then the tables would be more friendly. Gotcha, will change that also everything QuickOldCar said I will promptly get right on. @erdem I will check that out Check to make sure the column has changed before updating it. Also I'd update at row-level. Wait for focus to leave a row and then update it, assuming there's been changes. I can prob do the checking, but the row level might be a bit hard, but I will give it a try! Thanks for all the feed back I will get right to work once I wake up more!
  11. I didn't think to make one, here I just made it for everyone, took out the mysql_query on the update so as nothings changed in demo. http://siteofpurity.gotdns.com/sql/demo/ login is 'demo' pass is the same and yes its my own database but its from my test database so I don't have anything I need to hide.
  12. not sure where to post this rightly but I shall explain my....problem. Ok so I have been using PHP and JavaScript and HTML for the past three years and I have learned a lot and plan to become a Network+ engineer with programing webpages/sites on the side. So I was at my GF's rich parents house when her step dads company manger was there for a BBQ, I got to talking to her step dads co-workers and soon got to the manger, we chatted for awhile and I told him how theirs no free ajax driven MYSQL web editor, the paid ones were nice but flashy and did a lot more then basic need, the free ones.....well lets leave it at "free" and so I started creating my own, and I was happy with what I had made for myself. Well it turns out he took an interest in this easy MYSQL web editor and said that his employees have been complaining about using PHPmyadmin and how they wished for something easier and free with a simpler interface for updating information, I said I would fix up my script and send him a copy to test out on his server's, I did make a point to use it on a test server first. After a week I threw a copy into his email, about two days later he responds with; "This is great! This is what I was talking about and my employees after trying it out said it was just what they wanted to, And how you made it easy to update with just a simple link is amazing! Let me know when you have updated it to a stable release so I can put it to the production servers, looking forward to hearing back from you this month." Simple right? Hell it's great news and I might have just stuck my foot in the door to something big.....or have I? See I love what I have made and done the best to "fix it up" but I am so worried because I don't know how my Webware (that's what I call my stuff) will hold up to a database with tables holding millions of entry's (although I made it to handle as much as the webserver itself could) and the security too would be a problem, even though only about 25 people will be using it I still believe I need more testing with it and needs to be put through a lot more paces before pushing something like this on something so important. So I ask all of you out there, Help me? Could you tell me what I might have done wrong, what might need to change or I don't know, I just don't want to screw up this one chance by having one small little problem ruining their database and getting blamed or worse...sued. A copy of it will be Attached. And I please advise to test on a copy of XAMPP if you would be so kind to take it up to help me here. Sorry for the story life read their. [attachment deleted by admin]
  13. I get most of what your saying, but right now it just edits whats already there, I am still working on adding tables/databases, also adding a auto-inc column if they don't have one is something els I need to do, It's a one man project right now so it's hard to get a lot done but it is coming along nicely, Thanks for the reply again!
  14. If your table doesn't have a defined candidate key (i.e., an auto-increment field guaranteed to be unique), then by default, every field/attribute of the table/relvar in question are in the set of the sole composite candidate key. For instance, if you have a relvar/table A, with attributes attr1, attr2, attr3, ...attrN; and A has no explicitly defined candidate key; then by default, the the candidate key of relvar/table A is, say, CK. CK is a composite candidate key whose elements are the attributes of A, i.e., attr1, attr2, attr3, ..., attrN. This is the what Relational Theory teaches. In theory a table should strictly not contain duplicate rows, since relations are sets, and sets have no duplicates (in math). Now, in SQL, sadly, tables are not entirely the same with relations, even if those products are advertised as "relational." Now, how does it apply to you? 1.) For updating rows: Obviously, if a user didn't define an auto-increment field for some table A, then automatically, all the attributes of A are members of the sole candidate key. If so, instead of your WHERE clause being: UPDATE A SET attr1 = <some_new_value> WHERE auto_inc_field = <some_old_value>; It should be: UPDATE A SET attr1 = <new_value_of_attr1>, ..., attrN = <new_value_of_attrN> WHERE attr1 = <old_value_of_attr1> ... AND ... attrN = <old_value_of_attrN> I thought about that but what about if attr1 has 5 rows with the number 5? First one worked, and I forgot about DISTINCT When I tried that out it just threw up at me so I don't think that was it Thanks for taking the time to explain and stuff though, I learned something new and that's always good
  15. the links you posted I already knew about, it's when I go to update the data that just knowing which number the row is doesn't help when using the WHERE clause. I wanted it to work with every database no matter how it was setup but I guess relying on a auto-incrementing column isn't bad since just about everything has one. thanks for the help though
×
×
  • 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.