Jump to content

dr.pepper

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by dr.pepper

  1. Thanks for your quick response. Say someone didn't have a pop-up blocker or to open in new tabs, is there a way to do it?
  2. I know it's a bad idea but i've been asked by a client to develop a popunder. This means the window will pop up under (behind) the current window. When googling i've found a lot which don't do this and only pop up over the current window. Does anyone know of a script which works in this way and works in all browsers? The most common script seems the be the one below but this only pops up and not under. var popunder="http://www.yahoo.com" var winfeatures="width=800,height=510,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0" win2=window.open(popunder,"",winfeatures) win2.blur() window.focus()
  3. I have made the changes you suggested and I agree it is a lot neater and makes more sense. Thanks for both your input
  4. personaly...I think it looks a shambles, but it should work If you know a better or neater way then the advice would be really helpful? Thanks
  5. Actually, I think I seem to have done it now using the following query SELECT `o`.*, `p`.*, COUNT(*) as num FROM `orders` AS `o` INNER JOIN `orders_products` AS `p` ON o.order_id = p.order_id INNER JOIN `orders_products` AS `p2` ON o.order_id = p2.order_id WHERE (p2.product_id = '020577') AND (p.product_id !='020577') GROUP BY `p`.`product_id` ORDER BY num DESC LIMIT 3 This should return 3 of the most related products. Can you please have a check and confirm it looks ok?
  6. Thanks. You said to "COUNT(*) all of the products ever ordered together". Do you mean within the same query? The query I have so far which returns all related products is: SELECT `o` . * , `p` . * FROM `orders` AS `o` INNER JOIN `orders_products` AS `p` ON o.order_id = p.order_id INNER JOIN `orders_products` AS `p2` ON o.order_id = p2.order_id WHERE ( p2.product_id = '020577' ) AND ( p.product_id != '020577' )
  7. Thanks for your reply, I seem to be getting there now. SELECT * FROM `orders` o INNER JOIN orders_products p ON o.order_id = p.order_id INNER JOIN orders_products p2 ON o.order_id = p2.order_id WHERE p2.product_id = '24' GROUP BY p.product_id Tried the above which returns all related products. Would I group by p.product_id or p2.product_id? Also, where would I count the ordered products?
  8. I've got an 'orders' table which contains order_id sub_total total date I also have an 'orders_products' table which contains order_product_id order_id product_id product_name quantity price Therefore, the orders table contains a list of all orders and the orders_products lists all products associated to each order using the order_id field. Therefore, there could be multiple products within orders_products which have the same order_id. E.g Someone orders 2 books, 1 pen and 1 pencil. The order number is 17 so 17 will go into the orders table and the book, pen and pencil will go in the orders_products table with the order_id set to 17. What I need to do is find all related/similar items for each product. Therefore, the pen will be related to the book and the pencil because someone bought this in the same order, in the same way as the book will be related to the pen and pencil. So when someone clicks on the book detail page I need to find all related/similar products. Ideally, the products that have been in the same order the most times would appear first. E.g if the pen has been in an order with the pencil 20 times and the book only 2 times then the pencil would appear before the book on the pen detail page. I would also like to limit this to the 3 highest products. The first thing I assume I need to do is link the two tables so I have so far got the following query: SELECT * FROM `orders` o INNER JOIN orders_products p ON o.order_id = p.order_id I would then pass in the product_id that I want to find the related products for e.g if the pen was product_id 24 SELECT * FROM `orders` o INNER JOIN orders_products p ON o.order_id = p.order_id WHERE p.product_id = '24' I'm unsure where to go from here, if anyone can help?
  9. Yes. Not sure why. I can use HTML_entity_decode to get it like that though so would that help?
  10. I am looking for some help parsing the SOAP request below: try { $aSoapConnectionOptions = array( 'cache_wsdl' => WSDL_CACHE_BOTH, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'encoding' => 'ISO-8859-1', 'trace' => 1 ); $client = new SoapClient(WSDL_URI, $aSoapConnectionOptions); $xml = '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ReceiveData xmlns="GDWebService"> <value> <![CDATA[ <?xml version="1.0" encoding="utf-8"?> <XMLRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Description>EventsOnlyListLoad</Description> <Item xsi:type="XMLEventsOnlyRequest"> <RangeStartDate>01/01/2006</RangeStartDate> <RangeEndDate>01/12/2012</RangeEndDate> <ResType /> <ResView>Web Sales Events</ResView> </Item> </XMLRequest> ]]> </value> </ReceiveData> </soap:Body> </soap:Envelope>'; $response = $client->__doRequest($xml,REQUEST_URL,"GDWebService/ReceiveData",'1.1'); When I print out the response, I get the following: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ReceiveDataResponse xmlns="GDWebService"><ReceiveDataResult><?xml version="1.0"?> <ResourceList xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ResList> <anyType xsi:type="XMLEventsOnly"> <AVAILABLE>0</AVAILABLE> <EVENTNAME>Test Event</EVENTNAME> <RESTYPE>Families</RESTYPE> <TotalBooked>0</TotalBooked> <StartTime>11:00</StartTime> <ID>0069</ID> <EventCode>0000003701</EventCode> <EventDate>30/05/2011</EventDate> <EventDescription> </EventDescription> <Capacity>0</Capacity> <ProductMapID> </ProductMapID> <LongDescription> </LongDescription> <ImageLink> </ImageLink> <MINPERBOOKING>0</MINPERBOOKING> <MAXPERBOOKING>0</MAXPERBOOKING> <ValidFrom> </ValidFrom> <ValidTo> </ValidTo> <AdditionalInfo> </AdditionalInfo> <ValidDays> </ValidDays> <MoreInfoLink> </MoreInfoLink> </anyType> </ResList> <EventsOnly>false</EventsOnly> </ResourceList></ReceiveDataResult></ReceiveDataResponse></soap:Body></soap:Envelope> I want to be able to get the response as an object so I can easily loop through the ResList. Currently, the only way I seem to be able to do this is by doing the following but I know it's not the best code: $response = str_replace("xmlns=\"GDWebService\"", "", $response); $response = str_replace("soap:Body","body",$response); $response = simplexml_load_string($response); $response = $response->body->ReceiveDataResponse->ReceiveDataResult; $response = simplexml_load_string($response); if($response->ResList) foreach($response->ResList->anyType as $Item){ //echo data here } Hope someone can help. Thanks
  11. I think this now works correctly. Can someone else please try it for me using dates in the past and future? function getOverdueString($dueDate, $currentDate = 'now', $formatString = '%s%dd %dh %dm') { $a = strtotime($dueDate); if ($a === FALSE || $a === -1/*<5.1*/) return FALSE; $b = strtotime($currentDate); if ($b === FALSE || $b === -1/*<5.1*/) return FALSE; $diff = $a - $b; $sign = $diff < 0 ? '-' : ''; $diff = abs($diff); $days = floor($diff / 86400); $hrs = ($diff % 86400) / 3600; $mnts = (($diff % 86400) % 3600) / 60; return sprintf($formatString, $sign, $days, $hrs, $mnts); }
  12. Almost there! The following seems to work if I put the due date in the past e.g 29/07/2011 09:00:00 returns -1 day(s) -8 hour(s) -6 min(s) and -115607 second(s) However, if I do a due date in the future it seems to add an additional day on e.g 31/07/2011 09:00:00 returns 1 day(s) 16 hour(s) 57 min(s) and 57412 second(s) - this should be 0 day(s) 16 hour(s) 57 min(s) and 57412 second(s) shouldn't it?? <?php echo getOverdueTime("2011-07-31 09:00:00"); function getOverdueTime($sDate ) { $currentDate = time(); $sDate = strtotime($sDate ); $secsBetween = ($sDate - $currentDate); $days = $secsBetween / 86400; $days = floor($days)+1; $hours = ($secsBetween % 86400) / 3600; $hours = floor($hours)+1; $mins = (($secsBetween % 86400) % 3600) / 60; $mins = floor($mins)+1; return $days.' day(s) '.$hours.' hour(s) '.$mins.' min(s) and ' .$secsBetween.' second(s)'; } ?>
  13. Hi, Thanks for your help, is this only valid using PHP 5.3 though? Unfortunately, the server only has PHP 5 I thought I was on the right path with my initial post but unsure why this doesn't work now. Do you have a method for PHP 5?
  14. Getting there lol. The days no longer works, even my original doesn't. It now returns: By the way the date I am passing in is 2011-08-05 09:00:00 so not sure the hours are correct either?! 15185 day(s) 23 hour(s) 25 min(s) and 1311978297 second(s)
  15. Hmm, that returns: -15184 day(s) -22 hour(s) -21 min(s) and -1311978076 second(s)
  16. Hmm, not quite sure you understood the question? I've got the number of days already but I would like to get the hours and minutes too.
  17. Thanks for the response but what's the format_date method?
  18. Hi I have a date and I am looking to work out the number of days, hours and minutes between that date/time and the current date/time. If the current date is greater than the date then it must show the difference as a negative. Here are two examples: (from time of posting) Date 1: 20/07/2011 09:00:00 Date 2: 05/08/2011 20:00:00 The result of date 1 should be -9 days, 10 hours and 23 minutes The result of date 2 should be 7 days, 1 hour and 38 minutes The function I currently have and works for the number of days is the following: function getOverdueTime($sDate ) { $currentDate = time(); $sDate = strtotime(sDate ); $days = ($sDate - $currentDate) / 86400; $days = floor($days)+1; return $days.' day(s)'; } Can someone please explain how I would get the number of hours and minutes as well as the days?
  19. I've got an index.php page which then opens cars.php in a popup window using fancybox. However, the popup window is always too big for the content which is within it. I've googled it and assumed autoscale or autoDimensions would do the trick but unfortunately not. The content within cars.php can change depending on what I click on within index.php, therefore I can't set a static height and width. Is there any other way of doing it? cars.php contains a head and body tag which contains multiple images and some text.
  20. I have fixed it by changing the function name to checkBoxes because it had the same name as the actual checkbox.
  21. Yes I am getting this error: object doesnt support this property or method
  22. Here is the html: <label for="address" class="fmlabel">Address: <span>*</span></label> <input name="address" id="address" type="text" value="<?=stripslashes($_POST['address'])?>"/><br/> <label for="town_city" class="fmlabel">City: <span>*</span></label> <input name="town_city" id="town_city" type="text" value="<?=stripslashes($_POST['town_city'])?>"/><br/> <label for="county_state" class="fmlabel">County: *</label> <input name="county" id="county" type="text" value="<?=stripslashes($_POST['county'])?>"/><br/> <label for="name">Tick here if billing name and address are same as above.</label> <a style="cursor:pointer;font-size:12px;text-decoration:underline;" onclick="javascript:check();"><input id="check" name="check" type="checkbox" value="1"></a><br/> <label for="address" class="fmlabel">Address: <span>*</span></label> <input name="payment_address" id="p_address" type="text" value="<?=stripslashes($_POST['payment_address'])?>"/><br/> <label for="town_city" class="fmlabel">City: <span>*</span></label> <input name="payment_town_city" id="p_town_city" type="text" value="<?=stripslashes($_POST['payment_town_city'])?>"/><br/> <label for="county_state" class="fmlabel">County: <span>*</span></label> <input name="payment_county" id="p_county" type="text" value="<?=stripslashes($_POST['payment_county'])?>"/><br/>
×
×
  • 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.