Jump to content

coolbeansdude51

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

coolbeansdude51's Achievements

Member

Member (2/5)

0

Reputation

  1. I have an array of UTC times. Lets say its: 10:52:48 13:52:27 09:12:37 10:32:34 09:12:21 13:20:12 I need to find the average of the hours. I am trying to do a couple of things. 1. Find the average 2. Find out how many times that specific hour is in the array 3. Convert that UTC hour, second, microsecond to the users specific timezone. I am thinking something like this. I haven't fixed it for an array as of yet. $broken_time=explode(':','10:52:48'); $time=date('H:i:s',mktime(-6+$broken_time[0],0+$broken_time[1],0+$broken_time[2],0,0,0)); echo $time; Any ideas?
  2. I am working with time in PHP and MySQL. I need to store a timestamp into a mysql database when something occurs on my server. I then need to pull that from the database and display it to the user in the users specific timezone. I plan on storing the users timezone in the database as well. I need to be able to convert that time to different time zones easily and simply. Should I use: php time()/date() mysql datetime/timestamp What is the easiest way to convert this time variable? Thanks so much for your knowledge!
  3. After a ton of trial and error I figured it out. The or die(mysql_error()) was the problem. Cut that out and it works like a champ. Here's the code that works. if($error == 'yes') { $_SESSION['mes']['type'] = 'error'; unset($error); header('Location: send_message.php'); exit; } else { require('../lib/functions.php'); require_once('../db.php'); $content = sanitize($_POST['content']); $groups = $_POST['group']; foreach($groups as $g){ $query = "SELECT * FROM people, usersgroups WHERE usersgroups.userid = people.id AND groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { $test[$i++] = $row['phone']; }; }; }; var_dump($test); Any ideas why that would make it crap out?
  4. Its something to do with the while statement. If I comment it out it works fine. Humm. Idea's?
  5. Thanks for the reply michaellunsford! That didn't work ... Here is the entire piece of code I am working with. I hope this helps. if($error == 'yes') { $_SESSION['mes']['type'] = 'error'; unset($error); header('Location: send_message.php'); exit; } else { require('../lib/functions.php'); require_once('../db.php'); unset($error); $content = sanitize($_POST['content']); $groups = $_POST['group']; foreach($groups as $g){ $query = "SELECT * FROM people, usersgroups WHERE usersgroups.userid = people.id AND groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result) or die(mysql_error())) { echo $row['phone']; $test[$i++] = $row['phone']; }; echo 'test'; var_dump($test); }; }; It does echo out the $row['phone'] fine. Right now ... It doesn't even echo out the test or do a var_dump of $test. What am I missing? It seems like I am just not seeing something. Probably because I have yet to sleep ... go figure. Any suggestions anyone? Thanks for the help so far!
  6. OK. I tried it trying to not just echo out the data but add it to an array and that didn't work. Any suggestions? Here's the code: foreach($groups as $g){ $query = "SELECT * FROM people, usersgroups WHERE usersgroups.userid = people.id AND groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result) or die(mysql_error())) { echo $row['phone']; $test[] = $row['phone']; }; }; print_r($test); It echo's out the phone numbers but never adds them to the array ... any thoughts?
  7. That worked. Thanks for the help! The final code looks like this. Any suggestions? foreach($groups as $g){ $query = "SELECT * FROM people, usersgroups WHERE usersgroups.userid = people.id AND groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result) or die(mysql_error())) { echo $row['phone']; }; } }; [/]
  8. Hello all, Here's whats up. I have a form which has a list of groups. The list of groups correspond with a groupid field in the usersgroups table. Each user can have multiple groups. For each group that the user is in there is a record in the table. The $groups variable is the $_POST['group'] from the form. In the form they can select multiple groups. I have [] in the form so no worries there. I need to select different users in the groups and then add them to an array ($mailer[]) to process through a mailer function that we have. I don't get any mysql errors or anything. Everything checks out with that. Yet I don't get the expected results or desired results. Can you all check my logic and help me out. When I echo out $row["userid"] 14 comes out ... I don't have a user with 14 as the id or even in my database at all. I don't know how that happened. Thanks in advance for your wisdom! foreach($groups as $g){ $query = "SELECT * FROM usersgroups WHERE groupid = '$g'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result) or die(mysql_error())) { echo $row["userid"]; $query1 = "SELECT * FROM people WHERE id = '".$row["userid"]."'"; $result1 = mysql_query($query1) or die(mysql_error()); $row1 = mysql_fetch_array($result1) or die(mysql_error()); $mailer[] = $row1['phone'].$row1['provider']; }; }
  9. You are right ... I don't know much about normalization at all. Thanks for the idea! To make sure I understand you correctly. It would look something like this: record1 = member1 group1 record2 = member1 group2 record3 = member2 group1 Something to that effect ... Correct? Thanks for your reply and time. I really appreciate it.
  10. Hello all. Here is the problem. I have an application with users. I need to put those people into groups. Right now I have a separate table full of the groups. I query the groups table to place all the data in the form. Then I need to place data in table called members which has all the members data in it. Right now I have 1 field holding all the group data. I serialize the group array and then unserialize it when I need to pull it out. It works but I there has to be an easier way or a more correct way. I am running into problems when I need to build an msyql query to find members based on which groups they are in and then execute a script based on the members group association. Here are some thoughts: Would it just make more sense to create a field in the members table for each group? That would be a pain because the number of groups is constantly changing ... Pull in all the members into an array ... and the members groups then search through it building another array full of the members that meet the criteria ... Hopefully that makes sense. Let me know! Any idea's?
  11. @gizmola Thanks for your input. I misspoke when I said XML. I can get either XML or json. The majority of the data I gather is json data. (Its faster then XML with twitter ... go figure) Basically what we do is gather data about the people who are "following" a certain account on twitter. The problem lies in gather the appropriate data at the right time. We run it every hour so that we can get enough data to make our finding statistically relevant. The problem comes into play when the person who doesn't update there status since we last pulled the data. If they don't update there status for 1 full day that is 12 times that we pull data and the data says that for 12 times this 1 person has tweeted at the same time which skews our results. So we have to eliminate the people who have not changed there status and keep only the ones that have changed there status. All statuses have unique ids. We pull the unique id's place them in a DB then compare them the next time. If they changed and there are no duplicates then perfect. If there are duplicates we will throw away that set section of data but analyze the rest. When I mean analyze we only totals. Here is an example of what the data looks like in the database: timestamp id monday tuesday wednesday thursday friday saturday sunday UTCtime bestday num_records 2009-04-14 17:00:22 22 0 22 0 2 1 2 0 18:07:06 Tuesday 27 The data is then also summed up and then averaged once more to display the totals for the week. This will be done via a cron job and emailed out to the user on a day they specify. Does that help more??
  12. @humpty -- ahhh Yes? HAHAHA! Sorry! I am real tired. Thanks for your help!
  13. @Humpty -- Thanks for your knowledge! I didn't read your reply as well as I should have. My bad. You have been a tremendous help! Thanks so much! @Jason thanks for your comments as well. I have thought of keeping the entire xml data ... just not in the database. I was thinking using s3 to store it all. I am trying to keep my database as small and lean as possible. How would you suggest putting all of the status ID's in the database? One field that stores an array of them? Something to that effect. That just seems like a waste ... having 1 field where everything is stored ... I just had an idea!!! OK so follow me here. All I need to know is if the status is duplicated. So all I need to really know is if the ID's are duplicate. So if they are not a duplicate then that status ID can be deleted. Get it? If the ID's are found the second time then they need to be stored for a third time. If they arn't found then that's perfect and the ID's can be thrown away. What do you think? Does that make sense?
×
×
  • 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.