Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. I have a date in Mysql, which is a field called "created". It is in this format, "20111207045524". I can easily query to see if something is within a specific date range. I can also manage to do any other types of date work I have needed..however, there is one requirement I have never dealt with before. How do I get anything in the database that is 13 days past that date... To give you background...the person has a "Trial" offer...and that trial offer runs for 13 days. What I need to be able to do is tell which people are after their trial..but regardless of the start date. So if they were created on 11/15/2011..then if their account is past 13 days..I need to get that record. I am not sure if I am making much sense...but in essense everyone who has an expired date..I need to get..anyone who has gone more than 13 days past the created date... I can't figure out how to get the calculations correct on the date comparions..maybe it's just a slow moment for me today. Any advice is appreciated. $sql = "SELECT * FROM jp_subscriptions WHERE transaction_type = 'fp' AND created < '" . $last_date . "'"; $query = mysql_query($sql); Last Date, is the current date.
  2. That's what I was thinking. Just wanted to confirm it, thanks.
  3. Is it possible, to perform Checkin/Checkout functionality using just a web site, without associated mobile applications? Perhaps, using the Google Maps API..let someone checkin using the website..then record that checkin, then also record the checkout. Even without the checkout..is the checkin functionality possible...so they will basically show their location in a Google Map that people can see, when they perform a checkin. That is just the basics of what I need to do, but I want to make sure that part is possible first. I tried to do GPS functionality before without mobile, and I didn't see any viable solutions for this. Thanks.
  4. I understand now the entire difference between Group BY and distinct. Thanks..I have used group by before, but I didn't realize it worked in the way you described. Thanks for sharing that with me, it's working perfectly now.
  5. This is what I currently have...it's not working. Any advice is appreciated.
  6. This is driving me crazy. I have a table that has a lot of data in it. I have a field called Order ID that has multiple occurrences of each order ID. I need to be able to get 1 record with Each order ID. I basically tried using distinct..and it's still returning multiple occurrences of each order ID. $result = mysql_query("SELECT DISTINCT order_id FROM jp_transaction_history WHERE last_name LIKE '%" . $last_name . "%' AND transaction_type = 'ss'"); ALL I want to do is get 1 record for every Order ID that is found..not duplicate order ID's. Any advice, is appreciated.
  7. This does not make any sense... On the backend, I run the following script SELECT * FROM jp_transaction_history WHERE transaction_type = 'ss' AND order_date BETWEEN '2011-11-01' AND '2011-11-04' LIMIT 30 , 621 In PHPMYAdmin with no issues. On the front end...I can't get the query to run right. <?php require_once('functions.php'); $account_types = array('first', 'second'); $start_date = '2011-11-01'; $end_date = '2011-11-04'; foreach($account_types as $key_account => $value_account) { if ($value_account == 'ss') { $sql = "SELECT * FROM jp_transaction_history WHERE transaction_type = 'ss' AND order_date BETWEEN '" . $start_date . "' AND '" . $end_date . "'"; }else { $sql = "SELECT * FROM jp_transaction_history WHERE transaction_type = 'fp' AND order_date BETWEEN '" . $start_date . "' AND '" . $end_date . "'"; } echo $sql; $query = mysql_query($sql); echo mysql_num_rows($query); $sales_data = array(); while ($row = mysql_fetch_object($query)) { $action = unserialize($row->actions); $amount = $action[0]['amount']; if ($amount >= 1.95 && $amount <= 5.95) { // Extract dates from order ID $pointer = $row->order_date; // Setup defaults if (empty($sales_data[$pointer]['sent'])) { $sales_data[$pointer]['sent'] = 0; } if (empty($sales_data[$pointer]['declined'])) { $sales_data[$pointer]['declined'] = 0; } if (empty($sales_data[$pointer]['authorized'])) { $sales_data[$pointer]['authorized'] = 0; } if (empty($sales_data[$pointer]['qc_fail'])) { $sales_data[$pointer]['qc_fail'] = 0; } if (empty($sales_data[$pointer]['pp_cancels'])) { $sales_data[$pointer]['pp_cancels'] = 0; } if (empty($sales_data[$pointer]['apprd'])) { $sales_data[$pointer]['apprd'] = 0; } if (empty($sales_data[$pointer]['captured'])) { $sales_data[$pointer]['captured'] = 0; } // Populate values $sales_data[$pointer]['sent']++; $sales_data[$pointer]['authorized']++; $sales_data[$pointer]['apprd']++; if ($row->condition == 'complete') { $sales_data[$pointer]['captured']++; }else if ($row->condition == 'failed') { $sales_data[$pointer]['declined']++; $sales_data[$pointer]['authorized']--; $sales_data[$pointer]['apprd']--; }else if ($row->condition == 'canceled') { // Check second condition for PP Cancellations. $at_capture = 0; $at_complete = 0; $at_void = 0; foreach ($action as $k_capture=>$v_capture) { if ($v_capture['action_type'] == 'capture') { $at_capture++; }else if ($v_capture['action_type'] == 'complete') { $at_complete++; }else if ($v_capture['action_type'] == 'void') { $at_void++; } } if ($at_capture == 0 && $at_complete == 0 && $at_void == 1) { $sql2 = "SELECT * FROM callcenter WHERE orderid = '" . $row->order_id . "'"; $query2 = mysql_query($sql2); while ($row2 = mysql_fetch_array($query2, MYSQL_ASSOC)) { if ($value_account == 'ss') { if ($row2['status'] == 1) { $sales_data[$pointer]['pp_cancels']++; $sales_data[$pointer]['apprd']--; $temp_ppcancel = 1; } }else { if ($row2['second_status'] == 1) { $sales_data[$pointer]['pp_cancels']++; $sales_data[$pointer]['apprd']--; $temp_ppcancel = 1; } } // End value account if } // End while loop for row 2 } // End if for at capture }// End else if for row condition // Quality Assurance if ($temp_ppcancel != 1) { $sql3 = "SELECT * FROM callcenter WHERE orderid = '" . $value->order_id . "'"; $query3 = mysql_query($sql3); while ($row2 = mysql_fetch_array($query3, MYSQL_ASSOC)) { if ($value_account == 'ss') { if ($row2['status'] != 1) { $sales_data[$pointer]['qc_fail']++; $sales_data[$pointer]['apprd']--; } }else { if ($row2['second_status'] != 1) { $sales_data[$pointer]['qc_fail']++; $sales_data[$pointer]['apprd']--; } } } } unset($temp_ppcancel); } } // Sort Values ksort($sales_data); ?> <table class="tablesorter"> <thead> <tr> <th>DOWNLOAD</th> <th>DATE</th> <th>SENT</th> <th>DCLND</th> <th>AUTHD</th> <th>PRE-PRD</th> <th>QCFAIL</th> <th>APPRD</th> <th>CAPTURED</th> </tr> </thead> <tbody> <?php foreach($sales_data as $key=>$value) { echo '<tr>'; if ($value_account == 'ss') { echo '<td><a href="csv_download.php?type=ss&date=' . $key . '">Download CSV</a></td>'; }else { echo '<td><a href="csv_download.php?type=fp&date=' . $key . '">Download CSV</a></td>'; } echo '<td>' . $key . '</td>'; echo '<td>' . $value['sent'] . '</td>'; echo '<td>' . $value['declined'] . '</td>'; echo '<td>' . $value['authorized'] . '</td>'; echo '<td>' . $value['pp_cancels'] . '</td>'; echo '<td>' . $value['qc_fail'] . '</td>'; echo '<td>' . $value['apprd'] . '</td>'; echo '<td>' . $value['captured'] . '</td>'; echo '</tr>'; } ?> </tbody> </table> <br /><hr /><br /> <?php } ?> My code in PHP throws... If I cut the days down to just 2...or 1, it works fine. But for some reason these number of records throw memory errors..I am only running 2 queries to get data..one returns like 600, and the other one, less than that. Any feedback is appreciated, thanks.
  8. It's "Long Text" so I am good there. I just deleted all the data. I am going to manually turn it into an actual array first, then serialize it. That should work. Thanks for the feedback.
  9. I am taking an XML feed, and turning it into an array with $response = simplexml_load_string($results); Then I am turning the $response->actions which is an object, into a serialized string. Then saving it into a database table, as a varchar 225... it's not a large array though.
  10. I took an object, and saved it into a database serialized. $object_here = serialize($theobject); Then later on, I go and I get that data from a database, and try to unserialize it.. $objecthere = unserialize($row->theobject) And it throws the following error...any advice?
  11. INSERT INTO jp_transaction_history (transaction_id, order_id, condition, authorization_code, ponumber, order_description, first_name, last_name, address_1, address_2, company, city, state, postal_code, country, email, phone, fax, cell_phone, customertaxid, customerid, website, shipping_first_name, shipping_last_name, shipping_address_1, shipping_address_2, shipping_company, shipping_city, shipping_state, shipping_postal_code, shipping_country, shipping_email, shipping_carrier, tracking_number, shipping_date, shipping, shipping_phone, cc_number, cc_hash, cc_exp, cavv, cavv_result, xid, avs_response, csv_response, cardholder_auth, check_account, check_hash, check_aba, check_name, account_holder_type, account_type, sec_code, processor_id, tax, currency, cc_bin, product_sku, product_quantity, product_description, product_amount) VALUES (valueshere) Does anyone see any syntax errors with the first part of the statement. Mostly the list of fields..it's returning a syntax error on that part of the query, but that doesn't make any sense. Everything seems to be in order. Thanks.
  12. Yes, the ultimate value I have set it at now is 201. I might even expand that to closer to 500. This works out really well though. If it was just a few numbers and ONLY that I would leave it, but I had an old mentor of mine once taught me about Modulus in a similar situation..so I started thinking of him again and was trying to remember how to do it. That helped a lot, thanks again man.
  13. How can I write: if ($num == 1 || $num == 6 || $num == 11 || $num == 16 || $num == 21) { To use Modulus operator instead. Trying to figure out more about how to use it, so this is a good situation.
  14. I have stepped into more than one project with a function similar to the following: <? /** * xml2array() will convert the given XML text to an array in the XML structure. * Link: http://www.bin-co.com/php/scripts/xml2array/ * Arguments : $contents - The XML text * $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value. * $priority - Can be 'tag' or 'attribute'. This will change the way the resulting array sturcture. For 'tag', the tags are given more importance. * Return: The parsed XML in an array form. Use print_r() to see the resulting array structure. * Examples: $array = xml2array(file_get_contents('feed.xml')); * $array = xml2array(file_get_contents('feed.xml', 1, 'attribute')); */ function xml2array($contents, $get_attributes=1, $priority = 'tag') { if(!$contents) return array(); if(!function_exists('xml_parser_create')) { //print "'xml_parser_create()' function not found!"; return array(); } //Get the XML parser of PHP - PHP must have this module for the parser to work $parser = xml_parser_create(''); xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, trim($contents), $xml_values); xml_parser_free($parser); if(!$xml_values) return;//Hmm... //Initializations $xml_array = array(); $parents = array(); $opened_tags = array(); $arr = array(); $current = &$xml_array; //Refference //Go through the tags. $repeated_tag_index = array();//Multiple tags with same name will be turned into an array foreach($xml_values as $data) { unset($attributes,$value);//Remove existing values, or there will be trouble //This command will extract these variables into the foreach scope // tag(string), type(string), level(int), attributes(array). extract($data);//We could use the array by itself, but this cooler. $result = array(); $attributes_data = array(); if(isset($value)) { if($priority == 'tag') $result = $value; else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode } //Set the attributes too. if(isset($attributes) and $get_attributes) { foreach($attributes as $attr => $val) { if($priority == 'tag') $attributes_data[$attr] = $val; else $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr' } } //See tag status and do the needed. if($type == "open") {//The starting of the tag '<tag>' $parent[$level-1] = &$current; if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag $current[$tag] = $result; if($attributes_data) $current[$tag. '_attr'] = $attributes_data; $repeated_tag_index[$tag.'_'.$level] = 1; $current = &$current[$tag]; } else { //There was another element with the same tag name if(isset($current[$tag][0])) {//If there is a 0th element it is already an array $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; $repeated_tag_index[$tag.'_'.$level]++; } else {//This section will make the value an array if multiple tags with the same name appear together $current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array $repeated_tag_index[$tag.'_'.$level] = 2; if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well $current[$tag]['0_attr'] = $current[$tag.'_attr']; unset($current[$tag.'_attr']); } } $last_item_index = $repeated_tag_index[$tag.'_'.$level]-1; $current = &$current[$tag][$last_item_index]; } } elseif($type == "complete") { //Tags that ends in 1 line '<tag />' //See if the key is already taken. if(!isset($current[$tag])) { //New Key $current[$tag] = $result; $repeated_tag_index[$tag.'_'.$level] = 1; if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data; } else { //If taken, put all things inside a list(array) if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... // ...push the new element into that array. $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; if($priority == 'tag' and $get_attributes and $attributes_data) { $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data; } $repeated_tag_index[$tag.'_'.$level]++; } else { //If it is not an array... $current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value $repeated_tag_index[$tag.'_'.$level] = 1; if($priority == 'tag' and $get_attributes) { if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well $current[$tag]['0_attr'] = $current[$tag.'_attr']; unset($current[$tag.'_attr']); } if($attributes_data) { $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data; } } $repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken } } } elseif($type == 'close') { //End of tag '</tag>' $current = &$parent[$level-1]; } } return($xml_array); } ?> The strange thing is, this function seems to be used a lot, I even started using it. The issue however, is memory. When the xml is anymore than a small size, it causes out of memory errors while trying to use this function. Does anyone have a similar alternative that is better on the memory?
  15. Just to help out the readers out there, I got a good bit of it worked out. $todays_date = date("Y-m-d H:i:s"); $future_date = date("Y-m-d H:i:s", strtotime('+7 days')); $sql = "SELECT DISTINCT rets_oh_oh.LIST_NO, rets_oh_oh.Date_Time, rets_resi_sf.STATE as STATE, rets_resi_mf.STATE as STATE, rets_resi_cc.STATE as STATE, rets_resi_sf.STREET_NO as STREET_NO, rets_resi_mf.STREET_NO as STREET_NO, rets_resi_cc.STREET_NO as STREET_NO, rets_resi_sf.STREET_NAME as STREET_NAME, rets_resi_mf.STREET_NAME as STREET_NAME, rets_resi_cc.STREET_NAME as STREET_NAME, rets_resi_sf.TOWN, rets_resi_mf.TOWN, rets_resi_cc.TOWN, rets_resi_sf.REMARKS, rets_resi_mf.REMARKS, rets_resi_cc.REMARKS FROM rets_oh_oh LEFT JOIN rets_resi_sf ON rets_resi_sf.LIST_NO = rets_oh_oh.LIST_NO AND (rets_resi_sf.STATE = 'MA' OR rets_resi_sf.STATE = 'Massachusetts') LEFT JOIN rets_resi_mf ON rets_resi_mf.LIST_NO = rets_oh_oh.LIST_NO AND (rets_resi_mf.STATE = 'MA' OR rets_resi_mf.STATE = 'Massachusetts') LEFT JOIN rets_resi_cc ON rets_resi_cc.LIST_NO = rets_oh_oh.LIST_NO AND (rets_resi_cc.STATE = 'MA' OR rets_resi_cc.STATE = 'Massachusetts') WHERE rets_oh_oh.Date_Time >= '" . $todays_date . "' AND rets_oh_oh.Date_Time >= '" . $future_date . "' GROUP BY rets_oh_oh.LIST_NO LIMIT " . $offset . ", " . $limit; $query = mysql_query($sql); echo mysql_error(); while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) { echo '<pre>'; print_r($row); echo '</pre>'; } All I need to do now is filter states that are empty, and setup a few other filters, then I am good. Will post my final code when I am done to help anyone in the future who is messing around with convoluted joins.
  16. $sql = "SELECT DISTINCT LIST_NO, Date_Time FROM rets_oh_oh LIMIT " . $offset . ", " . $limit; $query = mysql_query($sql); echo mysql_error(); while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) { echo '<pre>'; print_r($row); echo '</pre>'; } I have 3 different tables with various property information. The listings in the code above, return the MLS number. The main thing is, that MLS number can be located in one of three different tables. Table1, Table2, or Table3. I am thinking that I was setting up a left join, below is what I have... $properties = array(); // This will contain the properties, no matter how we get them. $sql = "SELECT * FROM rets_oh_oh LEFT JOIN rets_resi_mf ON rets_resi_mf.LIST_NO = rets_oh_oh.LIST_NO LEFT JOIN rets_resi_sf ON rets_resi_sf.LIST_NO = rets_oh_oh.LIST_NO LEFT JOIN rets_resi_cc ON rets_resi_cc.LIST_NO = rets_oh_oh.LIST_NO LIMIT " . $offset . ", " . $limit; $query = mysql_query($sql); while ($property_row = mysql_fetch_array($query, MYSQL_ASSOC)) { if ($property_row['STATE'] == 'MA' || $property_row['STATE'] == 'Massachusetts') { if (!in_array($property_row['LIST_NO'], $properties)) { $properties[$property_row['LIST_NO']] = $property_row; } } } */ But there are a lot of issues. I only want to get unique list numbers, I only want to get a certain date range, I need to only get ones from a certain state and other things. I as in the process of doing a basic query, and then trying to use a PHP Array to strip them out...but since there is pagination, there are duplicates on alternate pages (page 2, and 3 and 4). Is there a way I can roll this into 1 query without it messing up.
  17. Alright, I have been trying to figure this out for myself awhile. I have a question. What are the technology extents of GPS tracking on the web? Using either PHP, Javascript or something else is there a way that I can get someone's GPS location from their phone in a web browser? I have a very large project that requires some decent GPS features....however, I have underestimated it..and I am at the point where I am about to have to tell the client we have to do this with Mobile apps. I wanted to try to make this happen using the web browser. It's going to be using Google Maps. I was hoping I can pinpoint their location pretty closely. Is this possible in a web environment.
  18. Ah good point. I forgot to split them with comma's. Thanks man.
  19. The datetime is messing up. On entry it works fine, on edit it messes up. My field is this:
  20. I have a Samsung Android Charge. I do a lot with note taking applications. I have downloaded a lot of them, and had no issues. Lately some of the files I am working with have been a little larger (I am talking about just 17kb or something...and I noticed every note taking app I try to use looks fine when I look at the note, ubt when I try to edit it, it gets cut almost in half, and then saves like that. After doing some research I found out Samsung has a hard limit on the amount of lines a text file can be....I have tried in extensive notes, ever notes, note everything and many others...is there any way at all to remove this limit and/or hack the phone to get rid of the limit.
  21. I did not create the image extension code. That is what is uses by default (Voxview). It automatically uses the image extension. That's what the built in default is.
  22. I am not sure. There are no errors. All I know is the application I am trying to use only accepts URL's that end with the image extensions. However, you can change the URL to support other URL's. That is what I am trying to do The way I can tell it's not working is by testing it after testing the regular expression, and it's not recognizing the URL because it's not been setup as allowed.
  23. The format I need to check for is this: http://media.mlspin.com/photo.aspx?mls=70741856&n=1 The code I am using right now is... $(document).ready(function(){ $(".yoxview").yoxview({allowedUrls: /\/photo.aspx\?mls=(?:\d+)&n=(?:\d+)$/i}); }); It's not seeming to work. Any advice is appreciated. I am decent at regular expressions, but still getting the hang of it.
  24. Cool, thanks for that. I appreciate it.
  25. Is there a way (in a Mysql Query) to only get zipcode results within a certain distance (Miles) of another zipcode? For example..if you were searching for zipcode 30082...and you wanted to get all results from the database that had zipcodes that were within 20 or 30 miles of the search zip code, is that possible.
×
×
  • 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.