WordPress.org

Ready to get started?Download WordPress

Forums

Template logic: Conditional display coding partially failing (2 posts)

  1. LDMartin1959
    Member
    Posted 1 year ago #

    I am a WP and PHP novice so I am in over my head, but that's only 'cuz I got thrown into the deep end of the pool. I am trying to add some logic to display content on certain pages, not on others. I've made some progress but having issues. Here is the plan:

    On certain pages with an post type of "EVENT" I want content to appear, but not on OTHER pages with an post type of "EVENT". The problem I am running into is that part of the content is appearing on ALL event pages even if they don't meet the criteria. The logic is intended to be this:

    If the page is post_type "EVENT", AND if the indicated table contains a field with a record CAT which matches the current "POST ID", AND contains a record TYPE which matches value "1", display table cells which contain text "Presented by: ", an href and an image, else display table cells which contain  .

    The problem is that the text "Presented by: " is appearing on ALL the even pages, regardless of whether they meet the criteria or not -- which would tend to indicate a problem with the logic code -- but by the same token the href and image are correctly appearing ONLY on the pages that meet the criteria and are NOT appearing on along with the rogue text on pages which do not meet the criteria.

    I am sure it is a coding error on my part but I am not sure what. ANY help anyone could give would be GREATLY appreciated. The code involved is below (oh, and I should mention that the code in question is in the HEADER.PHP file):

    if($post->post_type=='event') {
    
    $q1=mysql_query("SELECT *
    FROM table_name
    WHERE type = 1
    AND cat = $post->ID ");
    
    $row_diamond=mysql_fetch_object($q1);
    if ($q1){
    ?>
    <td width="115" align="right" valign="middle" id="diamond1"><strong style="position:relative;bottom:-25px;">Presented by: </strong></td>
    <td id="diamond2" width="190">
    &nbsp;
    <a href="<?=$row_diamond->website?>"  title="<?=$row_diamond->website_title?>" target="_blank"   style="cursor:pointer;"><img style="position:relative;bottom:5px;" src="<?php bloginfo('siteurl'); ?>/wp-content/plugins/sean_event/files/<?=$row_diamond->image?>" alt="<?=$row_diamond->alt_text?>"border="0"></a> <br />
    </td>
    <?php
    } else{
    ?>
    <td width="115" align="right" valign="middle" id="diamond1">&nbsp;</td>
    <td id="diamond2" width="190">&nbsp;</td>
    <?php
    }
    }
    ?>
  2. LDMartin1959
    Member
    Posted 1 year ago #

    display table cells which contain . should be:

    display table cells which contain a non-breaking space.

Topic Closed

This topic has been closed to new replies.

About this Topic