Jump to content

luminous

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

luminous's Achievements

Member

Member (2/5)

0

Reputation

  1. I have two tables with a structure as follows: Table 1: id_text - key long_desc Table 2: id_text - key id_product I'm trying to achieve returning an array as follows, where there are one to many id_products to each id_text fields: array( array( [id_text]=>1 [long_desc] = > Description goes here array( //product IDs [0]=>23, [1]=>17 ) ) ) at the moment I am retrieving a column for each and not grouped as above: Array ( [0] => Array ( [id_product] => 23 [long_desc] => Description goes here[id_text] => 1 ) [1] => Array ( [id_product] => 17 [long_desc] => Description goes here[id_text] => 1 can anyone help me? )
  2. You my friend are an absolute saint! This has really helped me out, I've created an object to handle everything much more neatly but I'd been staring at this thing for so long my brain had turned to moosh, I just needed someone to push me in the right direction! Thank you again, your time is very much appreciated :'(
  3. I've been stuck on this for about a week so I was wondering if I can get some help from you guys! Basically I'm exporting an array of values to a CSV file, within that array are two other arrays containing data I need. What I need to work out is how I can create a CSV with headers for these values, then with the nested arrays also print their values into the same rows as the first array. Example: $List = array ( 'Product ID' => '10', 'Customer Address' => '123 Fake Street', array( array('Product Name'=>'Product1', 'Product Price'=>'10.00', 'Product Reference'=>'HGJEN'), array('Product Name'=>'Product2', 'Product Price'=>'5.00', 'Product Reference'=>'HGJTN'), array('Product Name'=>'Product3', 'Product Price'=>'10.00', 'Product Reference'=>'HGJNN'), ), array( array('Product Customisation Name'=>'Additional Info', 'Customisation Value'=>'Things are great.'), array('Product Customisation Name'=>'Image Upload', 'Customisation Value'=>'Logo.jpg'), ), 'Telephone Number'=>'999', ); To be exported to something looking like this: Product ID Customer Address Product Name Product Price Product Reference Product Cus Name Cus Value Telephone Number 10 123 Fake Street Product2 5.00 HGJTN Additional Info Things are great 999 10 123 Fake Street Product1 10.00 HGJEN Image Upload Logo.jpg 999 10 123 Fake Street Product3 10.00 HGJNN [/td] [td] 999 If anyone could help me out in anyway I would be so appreciative, I'm sure this ones going to end up killing me!
  4. I'm setting a date using: $day = date("d")+1; However when I echo this result I get a single character rather than two i.e '7' and not '07', anyone know what could be up with this? I'm sure it's something to do with the '+1' because i create the current date with this code and returns with the format I want. Thanks!
  5. Sorry, Should of mentioned that! I'm using the 'move_uploaded_file' function in both instances.
  6. Just a question concerning the $_FILES['tmp_name'] field. I'm uploading a file which is being moved into two different locations. I run an 'If' check to see if either process fails but as I am running them both at the same time, when a $_FILES['tmp_name'] is moved, can it be used again? Both my functions run fine independetly but when I try run them both it doesn't work So my question is which may be seem fairly obvious: Once you move the $_FILES['tmp_name'] is it removed from the temp folder it's in? or is it copied? Thanks!
  7. I have the following tables: ordersl: id_order id_carrier id_lang id_customer id_cart id_currency id_address_delivery id_address_invoice customization: id_customization id_product_attribute id_cart id_product quantity quantity_refunded quantity_returned customization data: id_customization type index value I'm trying to get each value field from the customization data table where the id_cart field in the orders table is equal to the id_cart field in the customization field The relationships are as follows Orders [One to One] Customization Customization [One to Many] Customization data I'm really don't understand joins to well but here is the query I've been using and it returns the data i want (for this example it should return two fields of 'values') but is instead returning the values 12 times! I've tried all kinds of combinations of joins to try and get what I want but it doesn't seem to make a difference Here's the query I'm using: SELECT ps_customized_data.value FROM pres.ps_customization_field, pres.ps_customization_field_lang, pres.ps_orders INNER JOIN pres.ps_customization RIGHT OUTER JOIN pres.ps_customized_data ON ps_customization.id_customization = ps_customized_data.id_customization WHERE ps_orders.id_cart = ps_customization.id_cart AND ps_customization.id_customization = ps_customized_data.id_customization
  8. I'm rubbish with REGEX, I need help extracting a string between two characters like so: $date = "Wednesday, June 23, 2010"; preg_match ("/[,](.*)[,]/", $date, $matches); which gives me: Array ( [0] => , June 23, [1] => June 23 ) However I only want the second value (without the ',' at the beginning and the end) help me please!
  9. I know you can use group_concat to do this, however, is it possible to group the values from a column into seperate row values instead of just a single row value containing all the data?
  10. I'm having trouble trying to understand where to put a 'join' in this query, this returns: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ps_orders ON O.id_order = OD.id_order AI.id_address=id_address_invoice AND' at line 34 SELECT O.`id_order`, OD.id_order, O.`date_add`, O.`total_paid`, O.`total_shipping`, O.`delivery_date`, O.`invoice_date`, C.`id_gender`, AD.`firstname`, AD.`lastname`, AD.`company`, C.`email`, AD.`phone_mobile`, AD.`phone`, CONCATC(AD.`address1`, " ", AD.`address2`, " ", AD.`postcode`, " ", AD.`city`), CONCAT(AI.`address1`, " ", AI.`address2`, " ", AI.`postcode`, " ", AI.`city`), OD.`product_name`, OD.`product_quantity`, OD.`product_weight`, OD.`product_price`, CA.`name`, CL.`delay`, M.`name` FROM ps_carrier_lang AS CL, ps_carrier as CA, ps_orders AS O, ps_customer AS C, ps_order_detail AS OD, ps_manufacturer AS M, ps_address AS AD, ps_address AS AI LEFT OUTER JOIN ps_order_detail, ps_orders ON O.id_order = OD.id_order AI.id_address=id_address_invoice AND AD.id_address=id_address_delivery AND CA.id_carrier = O.id_carrier = CL.id_carrier AND C.id_customer=O.id_customer AND O.id_order = 28 Can someone please help?
  11. I'm using th PHP 'goto' function and I've just read you can't jump in or out of methods or loops which is probably why I'm having trouble with this code... $standard_shipping = array("4","5","6"); $free_shipping = array("1","2","3"); $mail_shipping = array("7","8","9"); goto first; first: foreach($standard_shipping as $standard) { if(array_key_exists($standard, $keys)) { $resultsArray = array_slice($resultsArray, 0,2); break; }else { goto second; } } second: foreach($free_shipping as $free) { if(array_key_exists($free, $keys)) { $resultsArray = array_slice($resultsArray, 6); break; }else { goto third; } } third: foreach($mail_shipping as $mail) { if(array_key_exists($mail, $keys)) { $resultsArray = array_slice($resultsArray, -3); break; } } How can I run through this type of method without using the 'goto' function?? Thanks in advance!
  12. splendid i think i can work with this, thankyou!
  13. Hi, I'm looking to see if there's an array function or method I can use to see if an array contains only one integer value. For example: Go through the array, if the array only contains the value 8 or multiple instances of the value 8:: do this else Go through the array, if the array contains the value 8 or multiple instances of the value 8 AND ANY OTHER NUMBER:: do something I've been working with 'in_array' but can seem to get the result I'm after :'(
×
×
  • 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.