2013-12-12 64 views
1

enter image description here目前我有代碼,做3件事情。將評論與圖片鏈接

  1. 它的圖像鏈接到使用iframe
  2. 它添加註釋
  3. 它顯示了評論的能力的可點擊的話。

我想要做的,如果可能的是讓顯示的評論與正在顯示的圖片綁定。然後當任何人提交評論時,它將被添加到與圖片關聯的評論的特定列表中。這可能嗎?

簡而言之,有一種方法可以將訪問表與另一個表中的一個特定條目鏈接起來。

這是我到目前爲止。

<cfquery datasource="AccessTest" name="qTest"> 
    SELECT Account, Image 
    FROM ElectricList 
</cfquery> 

<cfquery datasource="AccessTest" name="qTest2"> 
    SELECT Account, Image 
    FROM GasList 
</cfquery> 

<cfquery datasource="AccessTest" name="qTest3"> 
    SELECT Accounts, Remarks, Users 
    FROM Comments 
</cfquery> 

<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
     <title>Demo</title> 
    </head> 
    <body> 
     <h3>Demo</h3> 

     <iframe name="viewframe" style="display:block;height:Float;width:965px;float:left"> 
     </iframe> 

     <cflayout name="myAccordionLayout" type="accordion" width="600px"> 
      <cflayoutarea title="Electric Accounts" align="left"> 
       <cfoutput query="qTest"> 
        <tr> 
         <td> 
          <a href=#qTest.Image#" target="viewframe">#qTest.Account#</a> 
         </td> 
        </tr> 
       </cfoutput> 
      </cflayoutarea> 
      <cflayoutarea title="Gas Accounts"> 
       <cfoutput query="qTest2"> 
        <tr> 
         <td> 
          <a href=#qTest2.Image#" target="viewframe">#qTest2.Account#</a> 
         </td> 
        </tr> 
       </cfoutput> 
      </cflayoutarea> 
    </cflayout> 

    <table width="600" border="1" cellspacing="0"> 
    <cfoutput query="qTest3"> 
     <tr> 
      <td> 
       #qTest3.Accounts# 
       #qTest3.Remarks# 
       #qTest3.Users# 
      </td> 
     </tr> 
    </cfoutput> 

    <cfform name="insertComments" id="insertComments"> 
     <fieldset> 
      <p> 
       <label for="Accounts">Accounts</label> 
       <br/> 
       <cfinput type="text" name="Accounts" message="Please enter a Comment Title." validateat="onSubmit" required="yes" id="Accounts" size="60"> 
      </p> 
      <p> 
       <label for="Remarks">Remarks<br/></label> 
       <cftextarea name="Remarks" cols="55" rows="4" label="Tour Description" required="yes" validateat="OnSubmit" message="Please enter your comment here" enabled="no"> 
       </cftextarea> 
      </p> 
      <p> 
       <label for="Users">Submitters Name</label> 
       <br/> 
       <cfinput type="text" name="Users" message="Please enter your name here." validateat="onSubmit" required="yes" id="Name" size="10" maxlength="60"> 
      </p> 
      <p> 
       <cfinput type="submit" name="insertComments" value="Insert Comments" id="submit"> 
      </p> 
     </fieldset> 
    </cfform> 

    <cfif IsDefined("form.InsertComments")> 
     <cfquery datasource="AccessTest"> 
      INSERT INTO Comments (Accounts, Remarks, Users) 
      VALUES ('#form.Accounts#','#form.Remarks#','#form.Users#') 
     </cfquery> 
    </cfif> 
    </body> 
</html> 

回答

1

是的,假設您的當前表格中包含圖像以及ImageID鍵,您可以創建第二個表格以鏈接到關係中圖像表中的外鍵圖像ID。然後,在主表單中創建一個子表單以顯示/編輯評論。

這樣每個評論只鏈接到一個圖片,但每個圖片可以有多個評論。

編輯:按照本指南創建一個子窗體。

http://www.techonthenet.com/access/subforms/link.php

+0

我將如何創建子窗體 –

+1

添加鏈接子窗體嚮導 –

2

如果我正確地理解了你,你說圖像有更多或更多的評論。如果是這樣,這不是一個ColdFusion問題。您需要向數據庫中添加一個反映該關聯的表格。