Merge 2 rows into single row with data update?

hello all,
i have a table with below data,
declare @tbl table (uid int, uname varchar(10), start_dt date, end_dt date)
insert into @tbl values (1, 'env1', '4/4/2010', '5/5/2012')
insert into @tbl values (2, 'env2', '5/4/2010', '6/6/2012')
--earlier start data is '4/4/2010' from 'env1'
--latest end data is '6/6/2012' from 'env2'
insert into @tbl values (3, 'env1', '3/3/2010', '4/4/2012')
insert into @tbl values (4, 'env2', '2/2/2010', '5/5/2012')
--earlier start data is '2/2/2010' from 'env2'
--latest end data is '5/5/2012' from 'env2'
insert into @tbl values (5, 'env1', '8/8/2010', '12/12/2012')
insert into @tbl values (6, 'env2', '9/9/2010', '10/10/2012')
--earlier start data is '8/8/2010' from 'env1'
--latest end data is '12/12/2012' from 'env1'insert into @tbl values (6, 'envX', '9/9/2010', '10/10/2012')insert into @tbl values (6, 'envY', '9/9/2010', '10/10/2012')
i need to merge 2 rows for column  "uname" having value "env1" & "env2" to "envZ" and need to capture earlier start date and latest end date from both and update with new.
the desire output should be,
declare @tbl table (uid int, uname varchar(10), start_dt date, end_dt date)
insert into @tbl values (1, 'envZ', '4/4/2010', '6/6/2012')
insert into @tbl values (4, 'envZ', '2/2/2010', '5/5/2012')
insert into @tbl values (5, 'envZ', '8/8/2010', '12/12/2012')
insert into @tbl values (6, 'envX', '9/9/2010', '10/10/2012')
insert into @tbl values (6, 'envY', '9/9/2010', '10/10/2012')
note - i must need to update one row and delete other row as i can't insert new rows (having huge data with other columns also).
please suggest optimize query. thanks!

Which version and edition of SQL Server are you using?
Whenever there is a row with 'env1', there is a corresponding 'env2' and vice versa? 
The row with 'env2' is always after the row with 'env1'?   (uid+1)
If the answers are yes to both questions above, here's a possibility:
-- code #1 v3
;with
ENVZ as (
SELECT uid= case when T1.start_dt <= T2.start_dt then T1.uid else T2.uid end,
start_dt= case when T1.start_dt <= T2.start_dt then T1.start_dt else T2.start_dt end,
end_dt= case when T1.end_dt > T2.end_dt then T1.end_dt else T2.end_dt end
from @tbl as T1
inner join @tbl as T2 on T2.uid=T1.uid+1 and T2.uname='env2'
where T1.uname = 'env1'
MERGE
into @tbl as T3
using ENVZ as T4
on T3.uid = T4.uid
when matched and (T3.uname in ('env1','env2')) then
UPDATE set T3.uname= 'envZ',
T3.start_dt= T4.start_dt,
T3.end_dt= T4.end_dt
when not matched by source and (T3.uname in ('env1','env2')) then
DELETE;
The table @tbl is read three times in the above code. There are probably ways to optimize the above code. Or even other more efficient approach.
José Diz     Belo Horizonte, MG - Brasil

Similar Messages

  • 30EA1: Database mounted, can't get rows with DATEs

    I'm starting to use SQL Developer 3.0.02 build MAIN-02.37. I tried to use it with a 10g standby database that is only mounted, to check on its recovery progress, and it appears to NOT return rows with DATE columns in them. I've tried this with both a TNS connection and a basic connection. If the database is open, no problem.
    Example: select instance_name, host_name, startup_time from v$instance;
    If I remove the DATE column "startup_time" from the query, I get the expected rows. The Logging Page pane at the bottom shows ORA-01219 errors "database not open, queries allowed on fixed tables/views only."
    I get that ORA-01219 message in TOAD against the mounted standby database, but I also get all the rows including the DATE column when I run the exact same statement there.
    Is this a bug, or expected behaviour, or is there some setting I'm missing?
    Edited by: gmaccrim on Nov 25, 2010 4:26 PM

    I have similar problem on standby database with query on v$database.
    This query
    SELECT name,dbid FROM V$database
    works fine, but this one
    SELECT name,dbid,created FROM V$database
    doesn't return any row.
    I have Version 2.1.1.64 Build MAIN-64.45.

  • How can I merge 2 tracks into one track with iTunes 11?  I used to do it with iTunes/Advanced/Join Tracks, but iTunes 11 does not have an "Advanced" button.

    How can I merge 2 tracks into one track with iTunes 11?

    Thanks for your reply, Jim.  I imported a CD that I had burned previously with the 2 tracks of sound effects that I had downloaded from the internet (MP3 files), but I did not see an option to join the tracks when I imported the CD.  In the upper right corner there were three buttons: Options, CD Info, and Import CD.  When I click on Options, the drop-down menu has two choices: "Get Track Names"  and "Submit CD Track Names".   I cannot find an option to Join Tracks.  Help!

  • How to maintain dynamic rows with data when click on Previous button?

    Hi,
    I have 1 aspx page and divided into 3 pages using panels.Each panel has "Next" and Previous buttons
    I have created and deleted dynamic table rows when click on Add button using javascript. whenever i click on Next button it will navigate to same page of next panel.
    when i click on previous button then it goes to previous panel but whatever i have added dynamic table rows in 1st panel that got removed.
    Can u please help me for how to maintain state of dynamic table rows with entered data when click on Previous button?
    How to get dynamic table rows with entered data in previous panel when click on Previous button?
    Please find the below javascript code:
    function insertRow() {
    if (index >= 2) {
    document.getElementById('deleteRow').style.display = "inline";
    else { document.getElementById('DeleteRow').style.display = "none"; }
    var table = document.getElementById("myTable");
    var row = table.insertRow(table.rows.length);
    cell1 = row.insertCell(0);
    t1 = document.createElement("select");
    t1.options[t1.options.length] = new Option('--Select--', '0');
    t1.id = "ddlYear" + index;
    cell1.appendChild(t1);
    for (var i = 1975; i <= 2015; i++) {
    opt = document.createElement("option");
    opt.value = i;
    opt.text = i;
    t1.add(opt);
    t1.style.width = "155px";
    var cell2 = row.insertCell(1);
    t2 = document.createElement("Select");
    t2.options[t2.options.length]=new Option('--Select--','0');
    t2.options[t2.options.length]=new Option('State Board','1');
    t2.options[t2.options.length]=new Option('CBSE','2');
    t2.options[t2.options.length]=new Option('ICSE','3');
    t2.options[t2.options.length] = new Option('Others', '4');
    t2.style.width = "155px";
    t2.id = "ddlCourse" + index;
    cell2.appendChild(t2);
    var cell3 = row.insertCell(2);
    t3 = document.createElement("input");
    t3.id = "txtCity" + index;
    cell3.appendChild(t3);
    var cell4 = row.insertCell(3);
    t4 = document.createElement("input");
    t4.id = "txtInstitute" + index;
    cell4.appendChild(t4);
    var cell5 = row.insertCell(4);
    t5 = document.createElement("Select");
    t5.options[t5.options.length] = new Option('--Select--', '0');
    t5.options[t5.options.length] = new Option('English', '1');
    t5.options[t5.options.length] = new Option('Hindi', '2');
    t5.options[t5.options.length] = new Option('Telugu', '3');
    t5.options[t5.options.length] = new Option('Others', '4');
    t5.style.width = "155px";
    t5.id = "ddlMedium" + index;
    cell5.appendChild(t5);
    var cell6 = row.insertCell(5);
    t6 = document.createElement("input");
    t6.id = "txtSpecialization" + index;
    cell6.appendChild(t6);
    var cell7 = row.insertCell(6);
    t7 = document.createElement("input");
    t7.id = "txtFnl" + index;
    cell7.appendChild(t7);
    index++;
    function DeleteRow(index) {
    var table = document.getElementById("myTable");
    table.deleteRow(index);
    // if (index = 2) { alert("There is no rows added.Please add the new row"); }
    Design:
    <tr style="font-size: 12pt" id="trSecond" runat="server">
    <td colspan="3">
    <table id="myTable" width="100%" border="0">
    </table>
    <tr>
    <td colspan="3" align="right">
    <input type="button" title="Add" value="Add" onclick="insertRow();" />
    <input type="button" id="deleteRow" title="Delete" value="Delete Row" onclick="DeleteRow(this);" style="display:none" />
    </td>
    </tr>
    Thank you.

    Put the button click into an action listener and build the new frame there. The code I have below isn't exactly what you're doing (it's amazingly oversimplified), but it's probably similar enough to get your wheels turning in the right direction.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class sample
         public static void main(String[] args)
              JFrame frame = new JFrame("Sample");
              frame.setSize(400,400);
              Container content = frame.getContentPane();
              content.setLayout(new FlowLayout());
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JTextField text = new JTextField(10);
              content.add(text);
              JButton button = new JButton("Send");
              content.add(button);
              frame.setVisible(true);
              button.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        JFrame myframe = new JFrame("Results");
                        myframe.setSize(200,200);
                        Container mycontent = myframe.getContentPane();
                        mycontent.setLayout(new FlowLayout());
                        String mytext = text.getText();
                        JLabel label = new JLabel();
                        label.setText(String.valueOf(mytext));
                        mycontent.add(label);
                        myframe.setVisible(true);
    }

  • Load rows with date fileds include time

    Hi, I need to load rows with SQLLoader. The data has am field with date and time but using mask don4t load the time, only date. How do I load date and time?
    Thanks...

    The following should work to load both the date and time (as long as it is not rejected for some reason)date_cancel date "YYYY/MM/DD HH24:MI:SS"To display the date and time after it has been loaded, you will have to use on of the following:ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH:MI:SS AM';
    or
    SELECT to_char(<column_name,'DD-MON-YYYY HH:MI:SS AM') from <table_name>;

  • Merge form responses into single pdf

    I have 30 form responses and would like to combine them into a single pdf.  When I use the Merge Files Into Single PDF feature, the forms are combined into a single pdf, but the first form is duplicated 30 times.  In other words, the form fields on the other 29 forms are replaced with the data from the first form.  Can multiple form responses be combined into a singe pdf and the data be retained for each form?

    It is a bit late but I recently came across the same issue with combining mutliple PDF forms for which form fields have identical names. For example 100 people fill out the same PDF form and you need to combine them into one.
    I beleive you need to have Acrobat Pro
    1. File > Export > Export Multiple (This brings a dialog up where you can drag and drop a group of files.)
    2. Click OK
    3. Select EPS (Encapsulated PostScript)
    4. Click OK (Now you have .eps files of each PDF)
    5. Advanced > Print Production > Acrobat Distiller
    6. Select Standard
    7. Drag all the EPS files into Distiller
    PS - If anyone has a better solution please let me know!
    -Justin

  • How do I merge multiple windows into 1 window with several tabs?

    In Safari it is possible to merge several open windows into 1 single window, with each window becoming a new tab within the new window, so you can easily switch from tab to tab. I cannot find how to do this in Firefox - does anyone know if it is possible? Thanks.

    Try Tab Mix Plus.
    *Tab Mix Plus: https://addons.mozilla.org/firefox/addon/1122

  • SQL - Multiple Fetch into Single Column with Comma Separator

    Hello Experts,
    Good Day to all...
    I need your help on following scenarios. The below query returns set of titleID strings. Instead of printing them one below the other as query output, I want the output to be in batch of 25 values.i.e each row should have 25 values separated by comma. i.e If there are 100 titles satisfying the output, then there should be only four rows with and each row having 25 titles in comma separated manner.
    SELECT DISTINCT title_id
               FROM pack_relation
              WHERE package_id IN (      SELECT DISTINCT fa.package_id
                                                    FROM annotation fa
                                                GROUP BY fa.package_id
                                                  HAVING COUNT
                                                            (fa.package_id) <100);I tried with the PL/SQL block; whereas it is printing all the values continously :(
    I need to stop with 25 values and display.
    If its possible with SQL block alone; then it would be of great help
    DECLARE
       v_str   VARCHAR2 (32767)  := NULL;
       CURSOR c1
       IS
         SELECT DISTINCT title_id
               FROM pack_relation
              WHERE package_id IN (      SELECT DISTINCT fa.package_id
                                                    FROM annotation fa
                                                GROUP BY fa.package_id
                                                  HAVING COUNT
                                                            (fa.package_id) <100);
    BEGIN
       FOR i IN c1
       LOOP
          v_str := v_str || ',' || i.title_id;
       END LOOP;
       v_str := SUBSTR (v_str, 2);
       DBMS_OUTPUT.put_line (v_str);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line ('Error-->' || SQLERRM);
    END;Thanks...

    You can use CEIL
    Sample code
    SELECT
        nt,
        LTRIM(MAX(SYS_CONNECT_BY_PATH(val,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
    FROM
            SELECT
                val,
                nt,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val)    AS curr,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY val) -1 AS prev
            FROM
                    SELECT
                        level                          AS val,
                        ceil(rownum/3)  as nt /* Grouped in batches of 3 */
                    FROM
                        dual
                        CONNECT BY level <= 10
    GROUP BY
        nt
        CONNECT BY prev = PRIOR curr
    AND nt              = PRIOR nt
        START WITH curr = 1;
            NT CONCAT_VAL
             1 1,2,3
             2 4,5,6
             3 7,8,9
             4 10Your code
    SELECT
        nt,
        LTRIM(MAX(SYS_CONNECT_BY_PATH(title_id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS concat_val
    FROM
            SELECT
                title_id,
                nt,
                ROW_NUMBER () OVER (PARTITion BY nt ORDER BY title_id)   AS curr,
                ROW_NUMBER() OVER (PARTITION BY nt ORDER BY title_id) -1 AS prev
            FROM
                    SELECT
                        title_id,
                        ceil(rownum/25) AS nt /* Grouped in batches of 25 */
                    FROM
                        pack_relation tdpr
                    JOIN annotation fa
                    ON
                        tdpr.package_id = fa.package_id
                    GROUP BY
                        title_id,
                        fa.package_id
                    HAVING
                        COUNT (fa.package_id) < 500
    GROUP BY
        nt
        CONNECT BY prev = PRIOR curr
    AND nt              = PRIOR nt
        START WITH curr = 1;

  • Report generated through BIP Server not in sync with data updated in DB

    Hi,
    We have an issue where the BIP report show up the old value instead of the latest updated & commited value done from Application(ADF) on the same session or transaction.
    Does BIP have any caching mechanism implemented internally for a user context?
    Detailed Explanation :
    After verifying several scenarios, following are the scenarios which reproduced the cache issue in our application:
    Case -1:
    1) Logged in as user "User1".
    2) Navigated to page where we can update data and we have option to print/generate the report.
    3) Now made some updates in the page and saved it.
    4) Now generate the report, report is generated with the updated information.
    5) Now close the report generated and update the page with some other modifications and save it.
    6) Now generate the report, but the report doesn't have the updated info.
    Case-2:
    1) Logged in as user "User2".
    2) Navigated to page where we can update data and we have option to print/generate the report.
    3) Generate the print profile report, you see the changes made above with "User1" login.
    4) Now close the report generated and update the page with some more modifications and save it.
    5) Now generate the report, but the report doesn't have the updated info.
    Seems like, the request sent to BIP server is being cached at BIP server with its response considering the key with following format:
    <Login User-id> + <Request Parameters> .
    We are thinking this way because, in both Case-1 and Case-2, if we are modifying the request parameters values (fields to be shown in the generated report) uniquely for each new request,
    then we are seeing the changes updated in DB are present in the report generated.
    Can someone give inputs, how to overcome this issue?
    Thanks,
    Kiran Kumar

    if you are using the cold backup to create the standby database, Check that have you followed the following steps or not.
    1. remove
    all the datafiles and controlfiles from the standby database.
    2. Create a new standby controlfile of the production for standby using the following cmd
    'alter database create standby controlfile as 'Location';'
    3. move the new controlfile to standby database server location as specified in initialization parameter file.
    4. Restore all the datafiles to its appropriate loaction which was taken through cold backup.
    5. startup nomount
    6. alter database mount standby database;
    7. recover standby database.
    scp the archive log sequence that is asked by the database, from production.
    You can try this steps.

  • Rows into single column with comma seperator

    Hi Friends,
    I have the following Query
    select A.tradeid||','||A.TICKER||'|'||A.SUBORDINATION||'|'||A.CUSIP||'|'||A.DOCCLAUSE||'|'||A.CURRENCY from table A
    where A.ticker in ('LYME','GAADF') and A.tradeid in('456777')
    which is returning
    456777,LYME|SENIOR UNSECURED|Z1700990|MM|USD
    456777,GAADF|SENIOR UNSECURED|Z1246790|MM|USD
    I want the result set as:
    456777,LYME|SENIOR UNSECURED|Z1700990|MM|USD,456777,GAADF|SENIOR UNSECURED|Z1246790|MM|USD
    Please help me to get the result set
    Thanks,
    ragu.
    Edited by: user533548 on Apr 3, 2009 12:54 AM
    Edited by: user533548 on Apr 3, 2009 12:55 AM

    you could do
    select max (ltrim (sys_connect_by_path (tradeid||'|'||TICKER||'|'||SUBORDINATION||'|'||CUSIP||'|'||DOCCLAUSE||'|'||CURRENCY, ','), ','))
      from (
    select tradeid
         , ticker
         , subordination
         , cusip
         , docclause
         , currency
         , row_number() over (partition by tradeid
                                  order by null
                             ) rn
      from x)
    start with rn = 1
    connect by rn = prior rn + 1like in
    SQL> with x as
      2  (
      3  select 456777 tradeid ,'LYOE' ticker ,'SENIOR UNSECURED' subordination,'Z1830990' cusip,'MM' docclause,'USD'  currency from dual union all
      4  select 456777 tradeid ,'GAZDF','SENIOR UNSECURED','Z8446790','MM','USD' from dual
      5  )
      6  select max (
      7        ltrim
      8        (sys_connect_by_path (tradeid||'|'||TICKER||'|'||SUBORDINATION||'|'||CUSIP||'|'||DOCCLAUSE||'|'||CURRENCY
      9         , ',')
    10        , ',')) str
    11    from (
    12  select tradeid
    13       , ticker
    14       , subordination
    15       , cusip
    16       , docclause
    17       , currency
    18       , row_number() over (partition by tradeid
    19                                order by null
    20                           ) rn
    21    from x)
    22   start with rn = 1
    23   connect by rn = prior rn + 1
    24 
    SQL> /
    STR
    456777|GAZDF|SENIOR UNSECURED|Z8446790|MM|USD,456777|LYOE|SENIOR UNSECURED|Z1830990|MM|USD

  • Update multiple rows with datas from the same table

    i have a table like
    name version value1 value2
    2 A 4,31 3,5
    3 A 3,45 10
    2 B 6,97 12
    4 B 12 16
    so name + version is unique
    i have to update the datas value1 and value2 ( version A) with the datas from version B where the name ( VersionA) = name version B
    i.e the result should be
    name version value1 value2
    2 A 6,97 12
    3 A 3,45 10
    2 B 6,97 12
    4 B 12 16
    is it possible to do this in sql? ( sql. 8.1)

    ... if your table does not contain exactly what you expect you could get:
    'single row sub-query returns more than one row'
    To prevent that, put a unique index on (name, version). If this combination is not always unique, you will need to cater for the possibility in the update statement.

  • Display row with date search ADF 11g 11.1.1.2.0

    Hi
    I'm using jdeveloper 11.1.1.2.0 with ADF 11g.
    I'm want to display the table rows according to the date between search.
    My screen
    From ______ To ______ Seachbutton
    EMPNO EMPNAME JOINDATE
    001 JACK 04/05/2010
    002 JILL 02/05/2010
    003 PALIN 06/05/2010
    when i select date with adf input date in both text box and fire search . i want display the searched records/rows
    sorry ......
    thanks in advance
    Edited by: user9010551 on May 6, 2010 3:43 AM

    Hi
    I'm using jdeveloper 11.1.1.2.0 with ADF 11g.
    I'm want to display the table rows according to the date between search.
    My screen
    From ______ To ______ Seachbutton
    EMPNO EMPNAME JOINDATE
    001 JACK 04/05/2010
    002 JILL 02/05/2010
    003 PALIN 06/05/2010
    when i select date with adf input date in both text box and fire search . i want display the searched records/rows
    sorry ......
    thanks in advance
    Edited by: user9010551 on May 6, 2010 3:43 AM

  • Procedure to insert a new row with data, but no PK

    Ok,
    I have an assignment to insert a row into an existing table and to insert values (via a procedure) into certain fields. However, none of the fields that are to be INSERTED upon are the PK field.
    I wrote the following for a start, and I get an error since I have NULL in the PK field. The PK is named PRODUCTID. I am only to insert p_name, p_description, p_imgname, p_cost, and p_status. I am in school now, and am a beginner at PL/SQL, and any help would be appreciated.
    How can I do this without assigning a value to the PK field?
    For reference: there are 10 rows in the table, and the one I'm inserting is row 11.
    CREATE OR REPLACE PROCEDURE prod_add_sp
       (p_name IN bb_product.productname%type,
        p_description IN bb_product.description%type,
        p_imgname IN bb_product.productimage%type,
        p_cost IN bb_product.price%type,
        p_status IN bb_product.active%type)
       IS
      BEGIN
        INSERT INTO bb_product (idproduct, productname, description, productimage, price, active)
         VALUES (lv_prodid_num, p_name, p_description, p_imgname, p_cost, p_status);
    END;
    /

    > Ok, since the table had 10 rows (PK was numbers 1-10, I added number 11 in the PK field for the
    corresponding row.
    Any other way to do this?
    You want to use a number generator to give you a unique number to use as PRODUCT_ID. Such a generator is known as a sequence in Oracle. Like your products table, it needs to be created up front.
    E.g.
    create sequence product_id_sequence start with 1 increment by 1 nocycle nomaxvalue;
    Note that several "copies" of this sequence can be active at the same time to serve a number of concurrent requests. In other words, instead of everyone to queue to get a number from the sequence generator, it creates for example 10 queues and is able to service 10 requests at the same time. This is great for scalability and not creating a bottleneck. At the same time, the numbers handed out are unique but not in a gap free ascending sequence either. Which is fine. Relational design says that we need a UNIQUE number for a surrogate key. Not a gap free ascending number range.
    Okay, in your INSERT statement you need to add the PK column and add the next sequence value into it, e.g.
    INSERT INTO products ( product_id, .... ) VALUES( product_id_sequence.nextval, ... );
    Refer to the documentation URLs posted above on sequences for more details.

  • How To Find Last Row With Data +2, Then Format?

    I need to find the last row +2, select the range A:L, then format.
    Could someone please supply the code?  I can handle the format part.
    Thanks!
    A. Wolf

    Works great!
    I need to do 2 other things:
    1) Add a text value to r in A: & center over selection A:L
    Dim r As Long
        r = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
           USED THIS BUT ENDING UP IN MIDDLE OF L:!
        ActiveCell = Range("A" & r)
        ActiveCell.Value = "Estimated True Up Total"
    2) 2) Format a total in r as currency/2 decimels/aligned to right.
    THANKS AGAIN!!!
    A. Wolf

  • Put loop of variables into single array with formatting (PHP)

    I have the following loop;
    <?php
    $i=1;
    while($i<=$num_rows)
    $tempquantity = "extra".$i."quantity";
    $tempcomments = "extra".$i."comments";
    $tempname = "extra".$i."name";
    $tempprice = "extra".$i."price";
    $$tempquantity = $_POST['extra' . $i . 'quantity'];
    $$tempcomments = $_POST['extra' . $i . 'comments'];
    $$tempname = $_POST['extra' . $i . 'name'];
    $$tempprice = $_POST['extra' . $i . 'price'];
    print "Extra name: " . $$tempname;
    print "<br />";
    print "Extra price: " . $$tempprice;
    print "<br />";
    print "Quantity required: " . $$tempquantity;
    print "<br />";
    print "Client comments: " . $$tempcomments;
    print "<br /><br />";
      $i++;
    ?>
    Which, since there are 3 rows, outputs the following;
    Extra name: dfvgfddf
    Extra price: 4
    Quantity required: 67
    Client comments: gtfh
    Extra name: wewew
    Extra price: 34
    Quantity required: 45
    Client comments: thtrt
    Extra name: ewewe
    Extra price: 43
    Quantity required: 12
    Client comments: gdfgg
    What I want to be able to do is show the output above in a PHP email body variable, which I think this means that the loop of varaibles needs to be in one single array variable since coding in an email body variable is not allowed. How do I put a loop of variables like this into a single variable, and how to I keep the <br /> tags and names in front of the varaibles ('Extra name:' etc), so it looks as it should in the PHP email body?
    Thanks in advance

    Hi Murray,
    This is the code that sends the email;
    $to = "$renteremail";
    $subject = "Request confirmation";
    $headers = "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: website";
    $body = "
    Your reference number is <strong>$rrnumber</strong>.
    <br />
    <br />
    Below is a summary of your request details;
    <br /><br /><strong>Accommodation name</strong>: $accomm_name
    <br /><strong>Accommodation type</strong>: $accomm_type
    <br /><strong>Board-type</strong>: $ptbt
    <br /><strong>Max. capacity</strong>: $ptc
    <br /><strong>Check-in date</strong>: $passdate
    <br /><strong>Number of nights</strong>: $passnights
    <br /><br /><strong>Renter's name</strong>: $rentername
    if (mail($to, $subject, $body, $headers)) {$messagesent = 'yes';}
    So the three loop items with their four respective variables should go at the end of the list of variables above after 'Renters name'.
    I also need to put the variables generated by the loop into a single database feild, so if possible all should go into one variable.
    Thanks

Maybe you are looking for

  • Billing Doc is cancelled without excise invoice

    Hi, The excise invoice (j1iin) is still active but the billing document has been cancelled. Please suggest how can i stop it. Regards Prateek Saxena

  • Error 1402 HELP

    Thank you first for reading my post. I have read over the fourms for a few days now before posting. I would like to list some facts about my system and myself. I am very computer savy and I own and built this computer. I don't buy stock computers I h

  • Can a remote window be closed when the subvi is finished executing?

    I am dynamically calling subvi's from a main vi with the but when the remote user closes the browser window, it is causing problems with the connection. I would like to be able to programatically close the web window when the called subvi is done run

  • Syncing photo stream

    Why can all of my pics show on photo stream?

  • Yellow exclamation mark in references: What does it mean

    In my c# project, i have references to c++/cli and native c++ projects under "references". (i need to have them there, in order to be able to use msbuild on my solution from the command line.). all of these projects have yellow exclamation marks over