Display or Hide Recordset Data

Discussion in 'Software' started by thewackonerd, May 2, 2005.

  1. thewackonerd

    thewackonerd Private E-2

    I am trying to allow, via the admin section, the ability to change the background colours of a table.
    The problems I am having is as follows;
    - I have 4 of these sections on a dynamic template page
    - not all the sections are used each time the template is called
    - I want to either make the colours default to a specific colour if used or if not used, then to display a set colour

    I see 2 ways for this to happen;
    1 - if statements for the colours
    - or -
    2 - SQL statement to disallow the table to be shown unless content is posted in the database

    I am new to SQL and 'if' statements.
    I am using dreamweaver MX 2004 with access 2000.

    This is the code want to be able to hide, I have 4 of these section on a page.
    Code:


    ------------------------------------------------------------------------------------------------
    Code:
    <table width="150" border="0" cellpadding="1" cellspacing="0" bgcolor="#<%=(rs_pages.Fields.Item("S_SideHeading4_ColourBG").Value)%>">
                <tr>
                  <td>
                <table width="150"  border="0" cellspacing="0" cellpadding="4">
                      <tr>
                        <td align="center" bgcolor="#<%=(rs_pages.Fields.Item("S_SideHeading4_ColourBG").Value)%>"><strong><%=(rs_pages.Fields.Item("S_SideHeading4").Value)%></strong></td>
                      </tr>
                      <tr>
                        <td bgcolor="#<%=(rs_pages.Fields.Item("S_SideContent4_ColourBG").Value)%>">
                <%Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
    			objFile = Request.ServerVariables("SCRIPT_NAME")
    			ImagePath = Server.MapPath("../site_images\")
    			ImagePath = ImagePath & "\" & (rs_pages.Fields.Item("S_SideImage4").Value)
    			If objFileSystem.FileExists(ImagePath) then%>
                <img src="../site_images/<%=(rs_pages.Fields.Item("S_SideImage4").Value)%>" alt="ADC KRONE" border="0" align="right" /><%=(rs_pages.Fields.Item("S_SideHeading4").Value)%> 
                <%End If%>
                
                <%= CI_Preserve((rs_pages.Fields.Item("S_SideContent4").Value)) %>
                        </td>
                      </tr>
                  </table>
          </td>
        </tr>
    </table>
    ------------------------------------------------------------------------------------------------
     
  2. Kodo

    Kodo SNATCHSQUATCH

    it will be a combination of both. You should have a place to save your settings and a place to call them from i.e. your database. Then you can do 1 of 2 things.
    1. Check the db on each call to that page and check the setting.
    2. Set an application variable (based on setting in DB) after your application starts

    If the display is something that you want to control for all, then those two options are the best way to do it.

    Con's
    for #1: Hits the db every call to the page. If you have a lot of people hitting the page, then the db will slow down. (fyi, access is bad for making backend databases)
    For#2: It uses system memory. If your application restarts (IIS restarts) then the application variables are cleared. You must set them up again by using On_application_start in your global.asa

    I'd vote for #2 personally. It would be easier to manage. Each time you update the setting administratively, you simply do

    application.lock
    'update code here
    application.unlock
    then update the record in the db as well, just incase your app has restarted.

    You should also have a check on each page that requires it to see if those app vars are populated and if they are not, then call the db and update them. It's a bit more coding but not much really; and in my opinion, any time I can save a hit to the DB, I will.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds