Conditional content from 2 tables in PHP/MYSQL

I am developing a site in DWCS4 that has a database with 2 tables: audio and notes.
The tables contain the following fields:
AUDIO
audio_id (ai)
title (varchar)
filename (varchar)
(plus other fields for date, speaker etc)
NOTES
notes_id (ai)
audio_id (int) - foreign key
title (varchar)
file_location (varchar)
(plus other fields for date, author etc)
I have a page which lists audio files which enables a selection to be made that then leads to a page (audio_detail.php) which has full details of the audio and contains a player (see www.wscnf.org/audio.php).
Some of these audio files have associated notes and others do not - those that do contain the reference from audio.audio_id in notes.audio_id - if there are no notes then the foreign key defaults to a value of 0.
I have been asked to amend the audio_detail.php page so that, if there is an associated notes file, a link to that file is shown on the page - what I have in mind is if there are asscoiated notes, a new line appears beneath the player which says "Notes accompanying this audio are available:" followed by a download link. If there are no associated notes then this line does not appear.
Any assistance on how to achieve this would be most welcome - my knowledge of PHP/MYSQL is fairly basic (but growing!)

There are several ways to go about this, but the one that comes to mind is to use an outer join to select columns from both tables. The outer join will return results from the main table AUDIO regardless of if there are matching results in NOTES. You can then test the column values in NOTES. If the row has a NULL value in NOTES.notes_id, then there is no associate note for that row. If there is an notes_id value, then you can use conditional logic to display the NOTE details, link to other pages, etc.

Similar Messages

  • Copy contents from Webdynpro Table to Clipboard

    I have a requirement, wherein the contents from the table UI in Webdynpro, in an SRM system, have to be copied to a clipboard. The class CL_PERS_ADMIN->SET_DATA is the hint given for the same.
    Not sure how it works or how to implement this!?!
    Have gone through Web dynpro Selectoption: upload from clipboard and as per Harald's comment have also enabled 'Allow Programmatic clipboard access' in IE.
    Please advice.
    Edited by: Wincy J on Mar 23, 2011 9:30 AM

    Hi Wincy,
    Please check this...
    copy data from table
    Check this u understand
    https://wiki.sdn.sap.com/wiki/display/WDABAP/General+Issues#GeneralIssues-1.190
    Cheers,
    Kris.
    Edited by: kissnas on Mar 23, 2011 9:53 AM

  • How to create a vertical bar chart from a table? (PHP, HTML and CSS)

    Hi everyone,
    I have created a table and wish to proceed to do it even better in terms of analysis pattern. I want
    to create a vertical bar chart from the created table but I dunno how to start it.
    Here is the code for the table:
    <?php
    $gpa11=$_REQUEST['gpa11'];
    $gpa12=$_REQUEST['gpa12'];
    $gpa21=$_REQUEST['gpa21'];
    $gpa22=$_REQUEST['gpa22'];
    $gpa31=$_REQUEST['gpa31'];
    $gpa32=$_REQUEST['gpa32'];
    $gpa41=$_REQUEST['gpa41'];
    $gpa42=$_REQUEST['gpa42'];
    $gpa51=$_REQUEST['gpa51'];
    $gpa52=$_REQUEST['gpa52'];
    ?>
    <!doctype html>
    <html lang="en">
       <head>
          <meta charset="utf-8">
          <meta name="viewport" content="width=1024">
          <title>Feng Mentor Mentee</title>
       </head>
       <body>
          <div id="wrapper">
             <div class="chart">
                <h3>GPA Performance Graph</h3>
                <table id="data-table" border="1" cellpadding="10" cellspacing="0"
                summary="The performance of students throughout the years in university">
                   <thead>
                      <tr>
                         <td> </td>
                         <th scope="col">Year 1</th>
                         <th scope="col">Year 2</th>
                         <th scope="col">Year 3</th>
                         <th scope="col">Year 4</th>
                         <th scope="col">Year 5</th>
                      </tr>
                   </thead>
                   <tbody>
                      <tr>
                         <th scope="row">Sem 1</th>
                         <td><?php echo $gpa11;?></td>
                         <td><?php echo $gpa21;?></td>
                         <td><?php echo $gpa31;?></td>
                         <td><?php echo $gpa41;?></td>
                         <td><?php echo $gpa51;?></td>
                      </tr>
                      <tr>
                         <th scope="row">Sem 2</th>
                         <td><?php echo $gpa12;?></td>
                         <td><?php echo $gpa22;?></td>
                         <td><?php echo $gpa32;?></td>
                         <td><?php echo $gpa42;?></td>
                         <td><?php echo $gpa52;?></td>
                      </tr>
                   </tbody>
                </table>
             </div>
          </div>
       </body>
    </html>
    Here's the look:
                                                              GPA Performance Graph                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    Year 1
    Year 2
    Year 3
    Year 4
    Year 5
    Sem 1
    Sem 2
    Please help me on this because this is my 1st project on php.

    Hi
    Are you using BI query? If yes then follow the steps -
    1. Take Sales org in rows of BI query. & take invoice type & Key figure in Columns.
    2. In VC use this query & drag chart from the output of this query.
    3. Right click on chart & go to 'Configure Element'. There select Chart Type as 'Bar chart'
    4. Below that you will get default option as clustered, there you select 'Stacked'
    5. Create Data series as per your requirement.
    6. Arrange proper layout of the model & then deploy.
    You will get required output in stacked format.
    Regards
    Sandeep

  • Getting filter condition values from a table within the mapping

    I have a table say mytable with columns as name, age and maritalstatus. I have another table paramtable with the following structure parametername, parametervalue. The data in this would be like say
    Age >= 24
    Maritalstatus F
    Now from the table mytable I want to apply a filter which uses the values from the paramtable. Basically the filter condition should be something like
    mytable.age >= 24 and maritalstatus = F
    Any help on how this can be done within OWB?
    Appreciate all the help i can get

    rveluthattil wrote:
    I have a table say mytable with columns as name, age and maritalstatus. I have another table paramtable with the following structure parametername, parametervalue. The data in this would be like say
    Age >= 24
    Maritalstatus F
    Now from the table mytable I want to apply a filter which uses the values from the paramtable. Basically the filter condition should be something like
    mytable.age >= 24 and maritalstatus = F
    Any help on how this can be done within OWB?
    Appreciate all the help i can getoption 1. take table 1 and tabl2 into a joiner and apply this filter on the joiner.
    2. If table 1 has age and marital status then you can straightaway apply a filter with the condition without using table 2.
    if you are always going to link tabl1 and tab2 then perhaps using a joiner is the best way.
    Edited by: Darthvader-647181 on Nov 6, 2008 5:49 AM

  • Field name while fetching its content from db table dynamically.

    Hi Experts,
    I am new to ABAP and I  have a situation as follows.
    I have a table say ztable where there are seven fields monday,tuesday,wednesday,thursday,friday and saturday.
    Depending on the current calender day i have to fetch the content.
    Suppose for monday, i have to fetch ztable-monday.
    Is there any other way other than using if statements 7 times ? Like i wanna capture the day and substitute it in the place of z_table-"day".
    Please help.
    Thanks,

    Hi,
    In the below code you can pass any field of the table in W_FIELD.... It will fetch the particular field from the table....
    w_block should be of same data element of your field in W_FIELD
    PARAMETER : w_field TYPE NAME_FELD.
    DATA w_block(1) TYPE c.
    Select single (w_field) FROM RSEG INTO w_block
      WHERE belnr EQ '5105701294'.
      IF sy-subrc EQ 0.
        WRITE / w_block.
      ENDIF.
    Thanks and regards,
    Senthil Kumar Anantham.
    Edited by: Senthil Kumar on Jul 2, 2010 5:37 PM

  • Deletion of contents from database table

    Hi all,
    The purpose of the down program is to delete the entire contents from all the tables.  The deletion of the table should be in sorted manner.  Is there any other way to write the code more efficiently,
    TABLES: ZFFMCTL_AP, ZFFMHDR_AP, ZFFM_CHANGE_LOG, ZFFMDTL_AR, ZFFMHDR_AR,        ZFFMDTL_JV, ZFFMHDR_JV, ZFFMDTL_SKF,ZFFMHDR_SKF,ZFINVOICE_DETAIL,       ZFFMMASTER, ZFFMLOGREAD_CLUS, ZFFMCTL.
    DELETE ZFFMCTL_AP.
    IF SY-SUBRC = 0.
       DELETE ZFFMMHDR_AP.
       IF SY-SUBRC = 0.
          DELETE ZFFM_CHANGE_LOG.
          IF SY-SUBRC = 0.
             DELETE ZFFMDTL_AR.
             IF SY-SUBRC = 0.
                DELETE ZFFMHDR_AR.
                IF SY-SUBRC = 0.
                   DELETE ZFFMDTL_JV.
                   IF SY-SUBRC = 0.
                      DELETE ZFFMHDR_JV.
                      IF SY-SUBRC = 0.
                         DELETE ZFFMDTL_SKF.
                         IF SY-SUBRC = 0.
                            DELETE ZFFMHDR_SKF.
                            IF SY-SUBRC = 0.
                               DELETE ZFINVOICE_DETAIL.
                               IF SY-SUBRC = 0.
                                  DELETE ZFFMMASTER.
                                  IF SY-SUBRC = 0.
                                     DELETE ZFFMLOGREAD_CLUS.
                                     IF SY-SUBRC = 0.
                                        DELETE ZFFMCTL.
                                     ENDIF.
                                   ENDIF.
                                 ENDIF.
                              ENDIF.
                           ENDIF.
                        ENDIF.
                    ENDIF.
                 ENDIF.
               ENDIF.
            ENDIF.
         ENDIF.
    ENDIF.
    Waiting for response,
    Thanks in advance
    John

    Hello,
    you could employ the function modules DD_DROP_TABLE / DD_CREATE_TABLE. Purpose of these is to drop/create tables on DB-level.
    Regards Wolfgang

  • Conditional SELECT from 2 tables

    Hi, all
    What it the best way to implement that logic in SELECT when I'll select record with unique REC-ID from t_good but it’s exist in other t_change with same REC-ID I’l need to select from there.
    Something like IF EXIST, not sure how it works in Oracle. I see that I can JOIN all records from 2 table and check them later, but could be simpler way?
    If record with REC-ID exist in t_change
       Select  * from t_change 
    else
      Select * from t_ups_good  Tx
    Trent

    Since we don't know the data structure and don't have examples we are somewhat limited in providing you options. Since we aren't sure how or where you are doing this we are further limited in offering suggestions. With that said my first thought is to use a Union All.
    Select * from t_change where recid = [recid]
    Union All
    Select  * from t_ups_good where (Select Count(1) From t_change where recid = [recid]) = 0

  • Select a field having some content from a table

    Hi Friends,
    I had a requiremen where I need to fetch the field(having some content).
    I need to select FISTL field which is having some value (not space) from table BSIS into my internal table, so that I need to update this field value for all the line items with the same BELNR(doc number).
    My Approach:
        SELECT SINGLE FISTL FROM BSIS INTO WA_FINAL-FISTL WHERE FISTL IS NOT NULL AND
                                                               BELNR = WA_BSIS-BELNR.           
    But here if the first occurance of FISTL value in BSIS table in space, it is picking the spaces and updating my itab which means that a space value is not null.
    Please suggest me how to put condition so that I can select FISTL field having some value in it.
    Tried with read keyword also. But it is not accepting "IS INITIAL"  in where clause.
    Please look into this.
    Thanks,
    Murali

    Hello,
    You should try
    FISTL NE space
    instead of IS NOT NULL.
    As you might be aware ABAP data objects don't have 'NULL' values defined. You can use the 'NULL' values in Native SQL, but in case of Open SQL SAP says,
    "When reading with the Open SQL statement SELECT, null values can be created by aggregate functions or an outer join, but they are converted to initial values of the correct type when passed to data objects."
    Source: SAP documentation for NULL value.
    BR,
    Suhas

  • Export content from cluster table RSZWOBJ

    Hello,
    i need the html-cotent of the SAP BW cluster table 'RSZWOBJ'. I've tried this about the ABAP statement
    IMPORT FROM DATABASE rszwobj(bm) ID key
    but the results wasn' t very succesfully.
    The goel is to get the html-coding of the relevant BW-bookmark, to search this bookmark for an specific string, this string should be replaced for an another one. After this action the changed html string have to export to the cluster table 'RSZWOBJ'.
    If this procedure possible with the IMPORT-Statment or there are any another possibilities to change the content in the cluster  table 'RSZWOBJ'?
    With best regards
    Jurand

    Hey Sandra,
    thank you for your help. Your advice has solved the problem.
    With best regards,
    Jurand

  • DateField from Flex 4 to PHP-mysql

    Problem :
    when inserting a record from flex to mysql the date is reduced by 1 day.
    changes the date to 1 days ahead..like flex"13/12/2009" to mysql"12/12/2009"
    in Flex m15.POSTON = pOSTONDateField2.selectedDate;
    PHP is genereated by Flash Builder ..no changes in that.
    $item->POSTON->toString('YYYY-MM-dd HH:mm:ss')
    mySQL works fine.
    Here is the interesting bit..when I change my computer location from UTC +10( Australia) to UTC + 0..it works fine.
    changed the PHP setting date.timezone ="Australia/Brisbane"
    date_default_timezone_set('Australia/Brisbane');
    stilll same result..
    Why dose this happen how do I fix it.
    Thanks
    K

    We've converted our Flex base Ultimate DataGrid (http://www.flexicious.com/Home/Ultimate) to HTML (http://www.htmltreegrid.com/Home/Demo) with a with EXT JS, DOJO, or Jquery flavors. We have built AS - JS code converters, as well as display list/event dispatcher API ported to JS and are assisting customers with migration, if you are interested.

  • NEED HELP ASAP-populate contents from 5 tables into one master table

    Scenario:
    Assign a new_customer_id to each existing customer of our three business. A master lookup table (M) was given to me with pre-populated (SEQ_NOs), (NEW_CUSTIDs), and NULL in (OLD_CUSTIDS). My duty is to
    (1) Fill the M.OLD_CUSTID column with existing customer ids from T1, T2, T3 (uniquely).
    (2) Once the master lookup table is filled, add (SEQ_NO), and (NEW_CUSTID) column to the 3 existing customer tables to hold the new information.
    (3) At the end of the project, remove the existing customer ids from the T1, T2, T3.
    My problem is that there are no associations between the master table and existing customer tables (no keys). The code would be:
    update M
    set OLD_CUSTID= (select OLD_CUSTID from T1 where M.??=T1.??)
    Since the M.OLD_CUSTID and T1.NEW_CUSTID are NULL at this stage, and there are no keys to tie them together. I don't know how to fill both tables. Can someone help me ASAP? Thanks in Advance.
    -ORACLE Newbi

    I am building a "MASTER LOOKUP TABLE" to map the NEW_CUSTID and the OLD_CUSTID. The columns in this M table are:
    CREATE TABLE MKT.M
         "LOOKUP_SEQ" INTEGER, <=== from sequence
         "NEW_CUSTID" CHAR(6), <=== populated with strings given by biz analyst
         "OLD_CUSTID" INTEGER, <=== need to dump all existing custid (unique)
         PRIMARY KEY ("NEW_CUSTID") RELY NOVALIDATE
         ORGANIZATION INDEX TABLESPACE "MKT"
    Table T1/T2/T3 are slightly different but they all contain:
    CUST_ID INTEGER
    CUST_NAME CHAR(50)
    CUST_SINCE DATE
    CUST_ADDR1 CHAR(30)
    CUST_ADDR2 CHAR(30)
    DITY CHAR(30)
    STATE CHAR(2), etc.
    Since M is the lookup table for old-to-new customer ID mapping. There are no need to associat other than just enter the old IDs into the M table.
    Thanks for helping me. Any suggestion?

  • Show records from current user.  PHP, mySQL, CS3

    I'm stuck, can you help???
    I have a basic login page where the user is authenticated then directed to another page(User Home Page).  Works great!
    Problem is,...On the User Home Page, I'm trying to display the authenticated users data from the mySQL database but don't know how to retrieve that information and display it in the page.
    Can you help??

    David, looking through this post and the article to which it refers is getting me on the right track for what I want to do...but not completely. Perhaps you can help?
    I am using the Authenticate User behaviour to check the validity of a user against a current database, but instead of 'username' and 'password' I am using the two fields for 'firstname' and 'surname' as these are seperate columns in the current database. If the person is listed they are then taken to a page where I want to use both of the above as session variables to display the names in a new form, but also to act as filters to then bring forth further information from the database into the same form.
    I have tried the coding using the getUserDetails recordset that has been mentioned elsewhere in this thread, but obviously this has only the one filter.
    How can I add the second filter to the code?
    Is this possible?
    Thanks....Mark

  • Show a blob( pdf ) from db-table  in the clients browser/ web.show_document

    my env:
    Database R11_2 on one windows-host-machine
    AS 10 g on another windows-host-machine
    I can show files in Forms10g from inside the AS with web.show_document,
    that works fine
    but now I want to show a ( pdf or text ) File from a BLOB in a Table inside in the Database
    to the Browser running in Forms on AS,
    I do not want to create a extra Form for this reason, but want to show it in browser - windows
    ( how ) can I use web.show_document against a URL on the Database R11 ?
    what other tool , java ?
    regards

    Easiest way is probably to use mod_plsql and wpg_docload.download_file. If you retrieve the blob content from some table, than you can show it with a generic procedure like:
    procedure show_webdoc(io_blob          in out nocopy blob
                         ,i_mimetype       in varchar2
                         ,i_filename       in varchar2)
    is
    begin
       if dbms_lob.getlength(io_blob) >0 then
          owa_util.mime_header(nvl(i_mimetype,'application/octet'),false);
          htp.p('Content-length: ' || dbms_lob.getlength(io_blob));
          htp.p('Content-Disposition:  attachment; filename="'||i_filename|| '"');
          owa_util.http_header_close;
          wpg_docload.download_file(io_blob);
       end if;
    end show_webdoc;

  • Data from word tables to excel master spreadsheet

    Hello, I'm looking to take data from my damage report forms that come in maybe 20 times a week. This data needs to goto a master excel spreadsheet. I've managed to find a macro that does this but it does not paste it into excel the way I require and also
    extracts data I do not require.
    The word document contains a column of headings on the left, these will be the master spreadsheet sheet column headers. These will be on the spreadsheet already so I don't need them copied. 
    The other  two columns contains the data I will need to xfer to excel. I was thinking bookmarks can help here but I'm unsure if these will save over from the original template?
    So,  if there is some code out there that can help, brilliant. It will be an excel macro in the master spreadshee. TThat takestthe datadfrom the active word doc or by selecting the word doc in its folder. 
    Fingers crossed.
    Joseph 

    Hi Joseph,
    You should be able to run below code to get the data out of the Tabel(s) of a Word Document from within Excel.
    You can modify the code accordingly to your needs to specify the range where you want the data to be copied.
    I have already slightly modified the code to skip the header information.
    Sub ImportWordTable()
    Dim wdDoc As Object
    Dim wdFileName As Variant
    Dim TableNo As Integer 'table number in Word
    Dim iRow As Long 'row index in Excel
    Dim iCol As Integer 'column index in Excel
    wdFileName = Application.GetOpenFilename("Word files (*.docx),*.docx", , _
    "Browse for file containing table to be imported")
    If wdFileName = False Then Exit Sub '(user cancelled import file browser)
    Set wdDoc = GetObject(wdFileName) 'open Word file
    With wdDoc
    TableNo = wdDoc.tables.Count
    If TableNo = 0 Then
    MsgBox "This document contains no tables", _
    vbExclamation, "Import Word Table"
    ElseIf TableNo > 1 Then
    TableNo = InputBox("This Word document contains " & TableNo & " tables." & vbCrLf & _
    "Enter table number of table to import", "Import Word Table", "1")
    End If
    With .tables(TableNo)
    'copy cell contents from Word table cells to Excel cells
    ' start with row 2 to skip headers
    For iRow = 2 To .Rows.Count
    For iCol = 1 To .Columns.Count
    ' Define starting point here
    Cells(iRow - 1, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
    Next iCol
    Next iRow
    End With
    End With
    Set wdDoc = Nothing
    End Sub
    The source is this link:
    Export Word Table in Excel
    Also this Forum is more for generic Excel questions, for better response post in Excel For Developer Forum.
    Hope this helps,
    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"
    Please vote an answer helpful if they helped. Please mark an answer(s) as an answer when your question is being answered.

  • Want to fetch data from AFVU table with input of order number from AUFK table

    Hi,
    I have a requrement in report where in the user wil enter  the order number from AUFK table and it should display detais like job code condition code (from AFVU table) along with other fields. There is no relation ship between AFVU and AUFK. Can anybody help me in getting the replation ship between 2 tables. What is the table that iam missing and where can i find that relationship and fetch records for that order number?

    Check if this helps..
    AUFK -> AFKO -> AFVU
    AUFK-AUFNR = AFKO-AUFNR
    AFKO-AUFPL = AFVU-AUFPL
    Hope this helps.

Maybe you are looking for

  • Time Machine no longer showing external HD partitions

    I have two LaCie external drives attached to an iMac; one is used for Time Machine and the other is a multi-partitioned drive storing photos, movies, and music. If I bore down through the TM drive within Finder, I see folders for each backup instance

  • Default font size in the EXCEL launched by the Analyzer

    Dear All, We would like to have a change in the default font launched by the analyzer in the EXCEL. How can we go about it? Please enlighten. Regards, Tariq

  • Controlling # columns in interactive report's Group By format?

    Hi, I have an interactive report with columns category, attribute1 to attribute 6. I want to generate a report of sum of attributes 1-6, grouped by category column. I see the group by option of interactive report is limited to only 3 columns. Is ther

  • Reports on usage decision

    Dears I have a usage decision code like 1.Material passed in first test 2.Material passed in second test 3.Material passed in third test Now i need to get one report like How many UD i given by using 1.Material passed in first test,2.Material passed

  • Create users in different containers of a resource

    I have three resources A ( LDAP ), B ( LDAP ) and C ( Active Directory ). When new objects are created on resources B or C, they are created on resource A but always in the same container. Is it possible to select the container in resource A where I