Jump to content

PHP syntax - adding references to CSS amongst PHP loop


BarneyJoe

Recommended Posts

I have a page here, that uses a bit of PHP to loop a series of checkboxes.


 


I've posted a screenshot here:


 


http://www.handprintwebdesign.co.uk/gsg_checkboxes/


 


I have the stripes working, but not the rules for the checkboxes so that they don't appear with a border in IE.


 


So I have a couple of rules in my CSS:


 


.tickbox_odd {


          border: 0;


          background-color:#006;


}


.tickbox_even {


          border: 0;


          background-color: #990000;


}


 


And at the moment, the code I have looks like:


 


(the line in bold is the key line)


 


while ($keyword=mysql_fetch_assoc($query)) {


 


 


    //If new category close previous row & display new category


    if ($keyword['Category']!=$current_category) {


        if ($current_category && $column !=1 ) { echo "</tr>\n"; }


        $current_category = $keyword['Category'];


        echo "<tr class=\"categorycell\"><td colspan=\"10\">$current_category</td></tr>\n";


        $column = 1; $row_type="";


    }


 


 


//Create new row if 1st keyword


    if ($column == 1) {


        $row_type = ($row_type=="odd")?"even":"odd";


        echo "<tr class=\"".$row_type."\">";


    }


 


 


    //Display the checkbox


    echo "<td width=\"2%\">";


    echo "<input type=\"checkbox\" class=\"tickbox_".$row_type."\"";


    if (in_array($keyword['ActivityID'],$photokeywords)) { echo " checked"; }


    echo " name=\"ckbox[".$keyword['ActivityID']."]\" id=\"ckbox[".$keyword['ActivityID']."]\">";


    echo "</td>\n";


 


 


    //Display the Keyword


    echo "<td width=\"18%\" align=\"left\">".$keyword['Activity']."</td>\n";


 


 


    //Close the row if 5th keyword OR increase column count


    if ($column == 4) { echo "</tr>"; $column = 1; }


    else { $column++; }


}


 


 


if ($column != 1) { echo "</tr>"; }


 


But that isn't working - any help with this would be appreciated, just to get this detail tidied up.


 


Thank you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.