How to update multiple rows in one query using php

i am new to this can any one help me how to update multiple rows at a time i am doing an school attendance page

Often the situation is such that you have multiple courses across a range of dates.So students may take more than one course, and you need to track attendance for each course date. The following graphic demonstrates this:
In such a situation, you need four database tables as follows:
students (student_id, student_name, etc.)
courses (course_id, course_name, etc.)
students_courses (student_id, course_id)
attendance (student_id, course_id, dater)
A fifth table may also be needed to define the dates of courses, but you may also be able to build this array programmatically by using PHP's robust date functions, which can give you, for instance, all the Tuesdays and Thursdays between a start date and end date.
The students_courses table simply keeps track of which students are taking which courses, so it has just two columns for the primary keys of both of the main tables. The attendance table is similar, but it also includes a date field. The following view of the attendance table demonstrates this:
So if David's solution does cover your needs, consider yourself lucky, because this could quickly grow from a beginner-appropriate project to a moderately advanced one.

Similar Messages

  • How can update two rows in one query?

    How can update two rows in one query?
    Edited by: OracleM on May 4, 2009 12:16 AM

    What do you mean with "two rows"? May be two columns??
    If the where clause of UPDATE query matches two rows, then it will update two rows. If you want to update two columns, then add column names to your query
    UPDATE your_table SET col1=value1, col2=value2 WHERE your_where_clause- - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to update multiple records in the table using POST parameters:

    i got this idea from this website:http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-s ingle-sql-query/comment-page-1/#comment-5409. Basically i am trying to update all the status in the results page, and by adding $i in front of the id in the text fields, and checkboxes, i can name the different inputs with different names:
    The image of how it takes the inputs is shown here:http://forums.adobe.com/thread/709034?tstart=0
    I tried this but got this error:Parse error: syntax error, unexpected T_IF, expecting ')' in C:\xampp\htdocs\Database Query\results_change.php on line 51
    will not work in the update code section:
    for($i=0;$i<$maxRows_Recordset1;$i++)
    {$a=sprintf("%s",GetSQLValueString($_POST['changeid $i'],"int"));
    $b=sprintf("%s",GetSQLValueString($_POST['checkbox $i'],"text"));
    $display_order .= array(
        $a => $b
    if($i<$maxRows_Recordset1-1)
    $ids = implode(',', array_keys($display_order));
    $updateSQL = "UPDATE `change` SET Status = CASE Change_id ";
    foreach ($display_order as $a => $b) {
        $updateSQL .= sprintf("WHEN %d THEN %s ", $a,$b);
    $updateSQL .= sprintf("END WHERE `Change_id` IN ($ids)");

    Hi,
    Try
    BEGIN
      FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
        UPDATE xx_test
        SET checkbox = 'Y'
        WHERE rec_no = APEX_APPLICATION.G_F03(i);
      END LOOP;
    END;Code loops all checked checkbox. You do not need commit on page process.
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • How to get multiple rows at one time in a table?

    hi
    I have a JTable bound with ViewObject and i use multiple selection mode setting to get selection row.
    My question is when i select more then one row at one time i only can get those index from JTable but can't get those rows from ViewObject.is it possible to get rows from ViewObject? or how to use JTable row index to get row from ViewObject?

    repost

  • How to update multiple rows in ADF Tble

    Hi,
    I have created a search form and ADF table. This ADF table is having column of Select Boolean check box along with actual table columns.
    When I click on Search button it should show the result in ADF table. I will be able to select the check box in multiple rows.
    Finally when I click on Submit button status column should be updated against the rows for which Boolean check box is selected.
    Here the thing that I would like to know is how to identify the rows whichever are selected when I click on Submit button.
    Could you please help.
    Regards
    Vinod.

    http://sameh-nassar.blogspot.de/2009/12/use-checkbox-for-selecting-multiple.html shows how to use a checkbox via a transient attribute on the EO. To get the selected row you check the transient attribute of each row.
    Timo

  • How to extract multiple rows from a query and how to populate it in form.

    hi all,
    i want to populate multiple rows fetched from a cursor into form.
    i write this procedur.
    PROCEDURE populate_q (v_t_no IN number) IS
    cursor ext_q is
    select test_question.no, q_no, text, ans1
    from test_question , question
    where test_question.no = v_t_no;
    BEGIN
    for ext_rec in ext_q loop
         :take_detail.q_no := ext_rec.q_no;
         :take_detail.question := ext_rec.text;
         EXIT WHEN ext_q%notfound;
         end loop;
    END;
    and call this WHEN-NEW-BLOCK-INSTANCE trigger.
    this don't return all the rows only the lost one is populated
    and shown in form.
    thanks
    Muhammad Nadeem
    Mardan (pakistan)
    [email protected]

    Hi,
    look for the next_record built-in. Your cusror only addresses the current row, but you want to create new rows as you go
    Frank

  • Update multiple UDF from one query generator

    Hi All,
    I have Form1 with multiple UDF1 which have been key in by users
    And another Form2 with multiple UDF2 which exactly same with Form1 UDF1
    Is there a way that I can copy multiple UDF at Form2UDF2 from Form1UDF1 instead of creating query for each individual UDF, where in query generator I can select more the one column but only first column will be insert to the single UDF.
    Thanks

    Hi Firos,
    I mean I have 7UDF in the Payment Form where the information to this UDF are come from 7UDF in the invoice form which already created previously so I would like to copy those UDF from invoice to UDF in payment by using single query to capture all the UDF information by doing:
    SELECT T0.[DocNum], T0.[UDF1], T0.[UDF2], T0.[UDF3], T0.[UDF4], T0.[UDF5], T0.[UDF6], T0.[UDF7]
    FROM OINV T0 WHERE T0.[CardCode] = $[ORCT.CardCode]
    From above query can I pass the result directly to UDF in Payment Form? or I need to create one query for each individual UDF.
    Thanks

  • How to update multiple rows using cursor.

    hi all,
    i want to update rows fetched by a cursor. it don't update the rows.
    and gives error:
    ORA-01002     fetch out of sequence
    here is the trigger.
    Declare
         alert_id ALERT := Find_Alert('on');
         alert_button NUMBER;
         var number :=10;
         v_al char(3);
         v_al_da date;
         s_date date;
         al_on number;
         to_time number;
         cursor rem is
              select re_about, alarm, alert_date
              from remind
              where alarm='ON' AND alert_date = :control.showdate
              for update;
    begin
         for rem_record IN rem LOOP
              Set_Alert_Property(alert_id, ALERT_MESSAGE_TEXT, rem_record.re_about);
              al_on := show_alert('ON');
              IF alert_button = ALERT_BUTTON1 THEN
              update remind
              set alarm = 'OFF'
              --where re_about = rem_record.re_about
              where current of rem;
              ELSE
              NULL;
              END IF;
              COMMIT;
         END LOOP;
    end;
    thanks
    Muhammad Nadeem
    Mardan

    thanks dear,
    i tried the following code outside the loop
    but the same problem.
    here is the code:
    Declare
         alert_id ALERT := Find_Alert('on');
         alert_button NUMBER;
         var number :=10;
         v_al char(3);
         v_al_da date;
         s_date date;
         al_on number;
         to_time number;
         cursor rem is
              select re_about, alarm, alert_date
              from remind
              where alarm='ON' AND alert_date = :control.showdate
              for update;
    begin
         for rem_record IN rem LOOP
         Set_Alert_Property(alert_id, ALERT_MESSAGE_TEXT, rem_record.re_about);
              al_on := show_alert('ON');
              IF alert_button = ALERT_BUTTON1 THEN
              update remind
              set alarm = 'OFF'
         where current of rem;
              ELSE
              NULL;
              END IF;
         END LOOP;
    if :SYSTEM.FORM_STATUS = 'changed' then
         COMMIT;
    end if;
    end;
    thanks
    Muhammad Nadeem

  • How to update multiple records in a table using procedure?

    Dear All,
    1 am using 11.1.2.1.0
    my question is i have a table like
    emp id(primary key), empname,location
    1                             damby      blore
    2                             rocky       kormangala
    3                              biswa     india
    my question  is i need to write one procure that at a time i can update empname and location(wat the value are there in empname and location i  need to change at a time).
    thanks
    Damby

    Hi, Damby,
    That sounds like what the UPDATE statement does, exactly.  Just use an UPDATE statement to change any number of columns in existing rows.  You don't need a procedure, but, if you're using a procedure for some other reason, you can do the UPDATE in the procedure.  UPDATE works the same in SQL or PL/SQL.
    Sometimes MERGE is more convenient than UPDATE.  Like UPDATE, it can change any number of columns, either in SQL or PL/SQL.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to update many documents in one go using portal permissions

    Hello,
    I have two users in the portal with different permissions on a folder:
    rct2774: Total control
    rct3343: Read
    So, connected to the portal, rct3343 can´t upload (or erase) any document.
    Now, I´ve followed these instructions to update many documents in one go (found in "how to upload a folder containg HTML files in a KM folder" topic 22 - jun - 2006)
    "You can use the WebDaV.
    1. Get the WebDav path of your KM folder by going to details->properties->Access Links
    2. Copy the url for the WebDav
    3. Go to your desktop. Right Click on My Network Places.
    click on open.
    4. Click on add a network place.
    5. Click on "Choose another network location"
    6. Paste your copied url and click on next.
    7. Enter your portal userid and password. Now drag and drop your files from desktop. "
    But, updating this way both users (rct2774 and rct3343) can update, download and erase any document that belongs to that location.
    Do you know a way to update many documents in one go respecting or keeping the portal permissions?
    Thanks in advance.
    Best Regards,
    Esteban

    Hi Marc,
    First of all, thaks for your prompt reply. I´m new in these themes and any help is wellcome.
    We are doing many tests now, so we´re using the server portal as repository in itself. It´s quite strange because the permissions work at the portal correctly but not by the other way.
    Should I download the portal drive to the client PC for mantain the portal permissions?
    Thank you!

  • How to Update multiple items in other list using event handler?

    Hi All,
    If i update a item in a list, then i should update multiple items in another list need to be update. How to achive using event receivers?

    Hi Sam,
    According to your description, my understanding is that you want to update multiple items in another list when updated a list item.
    In the event receiver, you can update the multiple item using Client Object Model.
    Here is a code snippet for your reference:
    public override void ItemUpdated(SPItemEventProperties properties)
    string siteUrl = "http://sp2013sps/sites/test/";
    ClientContext clientContext = new ClientContext(siteUrl);
    List oList = clientContext.Web.Lists.GetByTitle("another list name");
    ListItem oListItem = oList.GetItemById(1);
    oListItem["Title"] = "Hello World Updated!";
    oListItem.Update();
    clientContext.ExecuteQuery();
    Best regards,<o:p></o:p>
    Zhengyu Guo
    Zhengyu Guo
    TechNet Community Support

  • How to update multiple columns from different tables using cursor.

    Hi,
    i have two tables test1 and test2. i want to udpate the column(DEPT_DSCR) of both the tables TEST1 and TEST2 using select for update and current of...using cursor.
    I have a code written as follows :
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
         LOOP
              FETCH C1 INTO v_mydept1,v_mydept2;
              EXIT WHEN C1%NOTFOUND;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
         END LOOP;
         COMMIT;
    END;
    The above code when run says that it runs successfully. But it does not updates the desired columns[DEPT_DSCR].
    It only works when we want to update single or multiple columns of same table...i.e. by providing these columns after "FOR UPDATE OF"
    I am not sure what is the exact problem when we want to update multiple columns of different tables.
    Can anyone help me on this ?

    oops my mistake.....typo mistake...it should have been as follows --
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    Now here is the upated PL/SQL code where we are trying to update columns of different tables --
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1,v_mydept2;
    EXIT WHEN C1%NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    END LOOP;
    COMMIT;
    END;
    Please let us know why it is not updating by using using CURRENT OF

  • How to update multiple row using procedure in table

    Hi,
    create or replace procedure TESTLEDGER1(var_date varchar2)
    as
    var_date1 date;
    CURSOR C1 IS
    select DISTINCT ta.accountid,day PROCESSDATE,
    (NVL(payment,0))PAYMENT,NVL(TOTALDUE,0)TOTALDUE,NVL(currentbillamount,0)CURBILL,NVL(srf,0)SRF,NVL(sbpnt,0)sbpnt,
    NVL(srv,0)SRV,NVL(sbf,0)SBF,NVL(SBV,0)SBV,NVL(EF,0)EF,NVL(EV,0)EV,NVL(TSRV,0)TSRV,
    NVL(tsub,0)TSUB,NVL(teqe,0)TEQE,NVL(DT,0)DT,
    NVL(A.dep,0)RDEP,NVL(B.DEP,0)PDEP,
    NVL(pnt,0)PNT,NVL(eqp,0)EQP,NVL(dtr,0)DTR,NVL(drf,0)DRF,NVL(unadj,0)UNADJ
    from
    (select DISTINCT day ,accountid
    from
    syntblmaccount, tblmtime where yyyy =2010)ta,
    (SELECT accountid,
    SUM(srfee)srf,
    SUM(srvat)srv,
    SUM(subfee)sbf,
    SUM(subvat)sbv,
    SUM(eqefee)ef,
    SUM(eqevat)ev,
    SUM(ttlsrv)tsrv,
    SUM(ttlsub)tsub,
    SUM(ttleqe)teqe,
    SUM(dep)dep,
    SUM(dt)dt,trunc(fromdate)fromdate
    FROM VWDT_v2
    GROUP BY accountid,trunc(fromdate)
    )a,
    (SELECT accountid,
    SUM(pnt)pnt,
    SUM(subpnt)sbpnt,
    SUM(eqpnt)eqp,
    SUM(dep)dep,
    SUM(DEPTRANSFER)dtr,
    SUM(DEPREFUNDED)drf,
    SUM(unadj)unadj,trunc(paymentdate)paymentdate
    FROM vwkt_v4
    GROUP BY accountid,trunc(paymentdate)
    )b,
    (SELECT ACCOUNTID,REFUND,trunc(createdate) createdate FROM vwrefund)F,
    ( SELECT ACCOUNTID,
    TRUNC(CREATEDATE)CREATEDATE,
    sum(TOTALDUE)/100 TOTALDUE,sum(currentbillamount)currentbillamount
    FROM SYNTBLTDEBITDOCUMENT
    group by ACCOUNTID, TRUNC(createdate))debit,
    (SELECT ACCOUNTID accountid,TRUNC(createdate)CREATEDATE, SUM(totalamount)PAYMENT
    from syntbltcreditdocument
    where CREDITDOCUMENTTYPEID IN ('CDT01','CDT04')
    -- AND ACCOUNTID='ACC000003014'
    group by accountid,TRUNC(createdate))credit
    where ta.accountid=a.accountid(+)
    and ta.accountid=b.accountid(+)
    --and ta.accountid=pay.accountid(+)
    and ta.accountid=debit.accountid(+)
    and ta.accountid=credit.accountid(+)
    and ta.accountid=f.accountid(+)
    and ta.day=a.fromdate(+)
    --and ta.day=pay.createdate(+)
    and ta.day=debit.createdate(+)
    and ta.day=credit.createdate(+)
    and ta.day=b.paymentdate(+)
    and ta.day=f.createdate(+)
    and trunc(ta.day)=to_date(var_date,'DD-MON-YY');
    begin
    select distinct processdate into var_date1 from ledgerdetail;
    FOR V1 IN C1 LOOP
    UPDATE LEDGERDETAILtest
    SET PAYMENT=v1.payment,
    TOTALDUE=v1.TOTALDUE,
    CURBILL=v1.curbill,
    SRF=v1.srf,
    SBPNT=v1.sbpnt,
    SRV=v1.srv,
    SBF=v1.sbf,
    SBV=v1.sbv,
    EF=v1.ef,
    EV=v1.ev,
    TSRV=v1.tsrv,
    TSUB=v1.tsub,
    TEQE=v1.teqe,
    DT=v1.dt,
    PDEP=v1.rdep,
    PNT=v1.pnt,
    EQP=v1.eqp,
    DTR=v1.dtr,
    DRF=v1.drf,
    UNADJ=v1.unadj
    where accountid=v1.accountid
    and processdate=v1.processdate;
    --DBMS_OUTPUT.PUT_LINE('INSERTED ROW');
    commit;
    end loop;
    end;
    I have created above procedure to update table column....but i am getting run time error....
    Error report:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "CRESTELVIEWSPRD501.TESTLEDGER1", line 70
    ORA-06512: at line 1
    01422. 00000 - "exact fetch returns more than requested number of rows"
    *Cause:    The number specified in exact fetch is less than the rows returned.
    *Action:   Rewrite the query or change number of rows requested
    how to resolve this error...
    Pl give me solution...
    thanks in advance.

    Hi:
    You have to make sure that join condition joins one record to one record not to a group of records.
    Saad,
    http://saadnayef.blogspot.com/

  • How to update multiple rows

    i have one array of string score1[]
    and i want to update those value in table
    how the query should be.........
    i thought it work as like for insert query
    but following is not working
    PreparedStatement ps = con.prepareStatement("update class_test_scores set score=? where student_id=? and test_no='fct' and subject_id=?");
    while(j<k)
         ps.setString(1, score1[j]);
         ps.setString(2, name[j]);
         ps.setString(3, subject);
         ps.executeUpdate();
         j++;
    }thanx & regards
    sweety

    tahnx for reply
    Akash_Ganga
    actually now it is working fine
    there was no error
    but the conformation page that i was displaying after updating
    was not loading
    now i got it correctly
    cheers & regards
    sweety

  • How to UPDATE multiple rows in T1 with unique value from T2

    Hi,
    having on mind update query with where clause:
    WHERE (SELECT LEFT(ColumnName,7) FROM tblName) = emp2.ColumnName
    error:
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
    The statement has been terminated.
    What am I suppose to change in WHERE clause....
    Note: there is always unique value in T2 while, in T1, there could be both, only one value to be updated or number of them that all need to be updated with that unique value from T2 (alias emp2)
    T1                                            
    T2
    colimn1          column2               column3        column4
    001A001A       string1                001A001       string10
    001A001B        string2                001A005      string20
    001B005A        string3               
    001B005B        string4
    001B005C        string5      
    should become:
    T1                                           
    colimn1          column2            
    001A001A       string10               
    001A001B        string10               
    001B005A        string20               
    001B005B        string20
    001B005C        string20      
    UPDATET1
    SET column2  = emp2.column4
    FROM  T2  as emp2
        WHERE (SELECT LEFT(column1,7) FROM T1 = emp2.column3                      

    Hi daredevil3011,
    Based on my test, the error is caused by where statement in the query. Just as the error message, in your where statement, there is a subquery “SELECT LEFT(ColumnName,7) FROM tblName” follows ”=”, this is not permitted in SQL Server.
    To fix this issue, please modify your query to like below:
    UPDATE T1
    SET column2 = emp2.column4
    FROM T2 as emp2
    WHERE LEFT(column1,7) = emp2.column3
    Reference:
    WHERE (Transact-SQL)
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for

  • Urgent HELP Needed Compressing 24 fps file to DVD m2v

    I am working in a project where all the source footage is 24fps film (in 720x486 uncompressed 8 bit QT files). I have edited the footage in FCP6 with the sequence at matching settings to the source footage. Every thing good so far. I then export out

  • How to set Dynamic variant  for a program

    Hello experts, I want to set variants dynamically on a selection screen. Please help me. Thanks, Ashwani.

  • Automate an ODI scenario

    Need to aumtomate an odi scenario with some conditions. Let me know any link on which all the related information regarding scheduling an odi scenario will be done.

  • Root filesystem corrupted, only var left

    Hi fellow Arch users! I was wondering if anybody would have an idea if it would be possible to restore packages and rebuild the system having only var partition. In short - I have had an encrypted system with var and home stored on separate hard driv

  • Read structure from main program class??

    Hi all, I know that i can read the structures from the main program with (program)structure But now the structure is in a class or form... How can i do this? regards