SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 52
  1. #26
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cronsrcs View Post
    PHP Code:
    mysql_select_db($database_Photolibrary$Photolibrary);
    $query_Keyword_Match sprintf("SELECT * FROM photokeywords WHERE Photo_ID = %s"$Photo_ID);
    $Keyword_Match mysql_query($query_Keyword_Match$Photolibrary) or die(mysql_error());
    $photokeywords = array();
    while (
    $row_Keyword_Match mysql_fetch_assoc($Keyword_Match)) {
        
    $photokeywords[] = $row_Keyword_Match['Keyword_ID'];
    }
    $totalRows_Keyword_Match mysql_num_rows($Keyword_Match);
    $sql "SELECT * FROM Keywords ORDER BY Keyword_ID";
    $keywordArray = array();
    $query mysql_query($sql);
    echo(
    '<table>');

    while (
    $result=mysql_fetch_assoc($query)) {
        
    $keywordArray[$result['Category']][] = $result;
    }
    $current_category '';
    foreach (
    $keywordArray as $categoryData)
    {
    if(
    $current_category <> $categoryData['Category'])
                {
                    
    //open a new <tr>
                    
    echo "<tr>\n";
                    
    //print the category as a header
                    
    echo "<td>"$categoryData['Category']."</td>\n";
                    
    //close the <tr>
                    
    echo "</tr>\n";
                    
    $current_category $categoryData['Category'];
                }       

        echo(
    '<tr>');
       
              
            echo(
    '<td><input ');
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) {
                echo 
    "checked ";
            }
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>');
            echo(
    '<td>'.$keywordData['Keyword'].'</td>');
            if (
    $counter==3) {
                echo(
    '</tr><tr>');
                
    $counter 0;
            } else {
                
    $counter++;
            }
        
        echo(
    '</tr>');
    }
    print_r($categoryData);
    print_r($photokeywords); 
    So with the above code you are getting all of the keywords and checkboxes, but just no category headings?
    No - with that one it's just showing 7 checkboxes, one on each row.

    But with that loop line back in towards the end, it is, ie :

    PHP Code:
    echo('<tr>'); 
        foreach (
    $categoryData as $keywordData) { 
              
            echo(
    '<td><input '); 
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    '<td>'.$keywordData['Keyword'].'</td>'); 
            if (
    $counter==3) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        echo(
    '</tr>'); 

    Can you do some debugging echo's such as after this line:
    PHP Code:
    foreach ($keywordArray as $categoryData)

    try
    PHP Code:
    echo "Current category is: " .$current_category."<br";
    echo 
    "Current keywords category is: " .$categoryData['Category']."<br"
    Current category is: x 7

    So presumably it's counting them (there are 7 categories), but not displaying them. I'll just away and try out what you said above - Category is the third column, ie table keywords : Keyword_ID, Keyword, Category

    And a blank with the 'Current keywords category is :' part.

    Also, what did the print_r show you?
    It seems that there is just a small glitch with the $categoryData['Category'] being echoes etc....I just want to see whether it is getting a var or not...
    the prints were as above - the first looking a bit odd, the second looking as you'd expect.

  2. #27
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ignore - dup post

  3. #28
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No worries, didn't know if you were around so jumped in - hope you dont mind
    spikeZ - absolutely not a problem!
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  4. #29
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cronsrcs View Post
    Ah...just a thought

    Try
    PHP Code:
    $categoryData['Category'][2
    or
    PHP Code:
    $categoryData[2]['Category'
    instead of
    PHP Code:
    $categoryData['Category'
    when attempting to refer to the category of the keyword.

    In your select statement when you select * from keywords....which column is the category? The 3rd one?
    OK - tried changing that error reporting line from :

    PHP Code:
    echo "Current keywords category is: " .$categoryData['Category']."<br"
    to

    PHP Code:
    echo "Current keywords category is: " .$categoryData['Category'][2]."<br"
    and

    PHP Code:
    echo "Current keywords category is: " .$categoryData[2]['Category']."<br"
    and also with [3]s, but no joy.

    Is the [2] there in reference to ['Category'] or in relation to $categoryData?

  5. #30
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aarrggh!

    I've been looking at this most of the day, and eventually spotted I'd changed something at one point to try out, and hadn't put it back whilst trying out the adding the [2]s etc.

    So I eventually spotted it, and it's virtually there with this code, in that the category headings have made an appearance :

    PHP Code:
    mysql_select_db($database_Photolibrary$Photolibrary); 
    $query_Keyword_Match sprintf("SELECT * FROM photokeywords WHERE Photo_ID = %s"$Photo_ID); 
    $Keyword_Match mysql_query($query_Keyword_Match$Photolibrary) or die(mysql_error()); 
    $photokeywords = array(); 
    while (
    $row_Keyword_Match mysql_fetch_assoc($Keyword_Match)) { 
        
    $photokeywords[] = $row_Keyword_Match['Keyword_ID']; 

    $totalRows_Keyword_Match mysql_num_rows($Keyword_Match); 
    $sql "SELECT * FROM Keywords ORDER BY Keyword_ID";
    $keywordArray = array(); 
    $query mysql_query($sql); 
    echo(
    '<table>');

    while (
    $result=mysql_fetch_assoc($query)) { 
        
    $keywordArray[$result['Category']][] = $result

    $current_category ''

    foreach (
    $keywordArray as $categoryData


    if(
    $current_category <> $categoryData[2]['Category']) 
                { 
                echo 
    "Current category is: " .$current_category."<br";
                    
    //open a new <tr> 
                    
    echo "<tr>\n"
                    
    //print the category as a header 
                    
    echo "<td>"$categoryData[2]['Category']."</td>\n"
                    
    //close the <tr> 
                    
    echo "</tr>\n"
                    
    $current_category $categoryData[2]['Category']; 
                }       

        echo(
    '<tr>'); 
        foreach (
    $categoryData as $keywordData) { 
              
            echo(
    '<td><input '); 
            
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    '<td>'.$keywordData['Keyword'].'</td>'); 
            if (
    $counter==3) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        echo(
    '</tr>'); 

    The minor sorts of issues now are formatting - possibly HTML issues, but not sure how it works with it being mixed in the PHP.

    For example, this part displays the checkboxes and keywords, and limits it to 4, ie what would be 8 columns in a table.

    PHP Code:
    echo('name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    '<td>'.$keywordData['Keyword'].'</td>'); 
            if (
    $counter==3) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
    The trouble is that the line that displays the category header isn't spanning the four checkbox / keyword 'columns', so is being squashed into a width of a bit more than an inch.

    Which in turn is knocking out the spacing below - ie there's a similar gap between the left most checkbox, and it's associated keyword :

    ie

    Places of
    Interest

    x keyword x keyword x keyword x keyword

    Instead of

    Places of Interest

    x keyword x keyword x keyword x keyword

    If you get me?

    The most obvious thing to try was changing

    PHP Code:
    echo "<td>"$categoryData[2]['Category']."</td>\n"
    to

    PHP Code:
    echo "<td colspan="8">"$categoryData[2]['Category']."</td>\n"
    But that just errored out -

    Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in C:\wamp\www\Photolibrary\editPhotoKeywords.php on line 164

    Which I guess is unsurprising, as the 'columns' are being virually created using the array, rather than an actual HTML table.

    Any ideas if this can be tidied up?

    If possible, it would be good to style alternate rows - I've got some code, but might need a bit of help fitting it in.

    A big big thank you for your help and patience with this tho' - very much appreciated.

  6. #31
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    change this line:
    PHP Code:
    echo "<td colspan="8">"$categoryData[2]['Category']."</td>\n"
    to

    PHP Code:
    echo "<td colspan=\"8\">"$categoryData[2]['Category']."</td>\n"
    Notice the "\" that are used to escape the quotes when echoing out html - that will sort the error that you are getting.....

    Let me know if this sorts the formatting issue - and then we can look at the alternating rows
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  7. #32
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup - that fixed that one.

    I did have a bit of code for the alternating thing, but tink I've lost it whilst doing this, after it wasn't working.

    I'll have a rummage tho'.

  8. #33
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK - this is it adapted with the sort of code I was thinking of - but it's not quite right :

    PHP Code:
    foreach ($keywordArray as $categoryData


    if(
    $current_category <> $categoryData[2]['Category']) 
                { 
                    
    //open a new <tr> 
                    
    echo "<tr>\n"
                    
    //print the category as a header 
                    
    echo "<td colspan=\"8\">"$categoryData[2]['Category']."</td>\n"
                    
    //close the <tr> 
                    
    echo "</tr>\n"
                    
    $current_category $categoryData[2]['Category']; 
                }       

        
    // Define your colors for the alternating rows<br>  
        
    $color1 "#E9FEEA";  
        
    $color2 "#FFFFFF";  
        
    $row_count 0


        echo(
    '<tr>'); 
        
        
    $row_color = ($row_count &#37; 2) ? $color1 : $color2;
        
        
    foreach ($categoryData as $keywordData) { 
              
            echo(
    '<td bgcolor=\"$row_color\"><input '); 
            
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    '<td>'.$keywordData['Keyword'].'</td>'); 
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        echo(
    '</tr>'); 


    // Add 1 to the row count 

        
    $row_count++; 

  9. #34
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I generally create a couple of styles in my .css file for the alternate row colours...

    eg
    HTML Code:
    .odd_row{
    background-color: #FAEBD2;
    }
    
    .even_row{
    background-color: #C6897D;
    }
    Then in the php code do something like this:
    PHP Code:
    //even row
    if($row_count%2==0)
    {
        
    $row_type 'even';
    }
    //odd row
    else
    {
        
    $row_type 'odd';            
    }
    //echo the<td>itself
    echo "<td class=\"".$row_type."\"><input "
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  10. #35
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That makes sense.

    I added the CSS as per your post, and changed the PHP to :

    PHP Code:
    echo('<tr>'); 
        foreach (
    $categoryData as $keywordData) { 
            
            
    //even row 
    if($row_count%2==0

        
    $row_type 'even'

    //odd row 
    else 

        
    $row_type 'odd';             


            
            echo(
    '<td class=\"".$row_type."\"><input '); 
            
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    '<td>'.$keywordData['Keyword'].'</td>'); 
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        echo(
    '</tr>'); 

    But no joy - I thought maybe the $row_type = 'even'; should have been $row_type = 'even_row'; (as per the CSS), but it wasn't that.

  11. #36
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes apologies - it should have been .odd and .even in the css.

    In my code I am using <tr class="odd">

    as opposed to <td class="odd">......I think that maybe the problem - ie the css not being applied to the td itself - check the source of your html to see whether it is being printed in the html code at all.
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  12. #37
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't quite get it -

    A straightforward <tr class = "even"> works fine.

    And

    PHP Code:
    echo('<td><input '); 
            
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    "<td class=\"even\">".$keywordData['Keyword'].'</td>'); 
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        echo(
    '</tr>'); 
    Sees the CSS,

    and

    PHP Code:
    //even row 
    if($row_count&#37;2==0) 

        
    $row_type 'even'

    //odd row 
    else 

        
    $row_type 'odd';             

            
            echo(
    '<td><input '); 
            
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    "<td class=\"".$row_type."\">".$keywordData['Keyword'].'</td>'); 
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        
        echo(
    '</tr>'); 

    Is colouring every populated TD with the even colour.

    I tried adding in

    $row_count++;

    In a couple of likely looking spots near the end of that, but didn't fix it.

  13. #38
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this line:

    if($row_count&#37;2==0)

    should be
    if($row_count%2==0)

    i am not sure if that is just the forum changing that character or whether your code has that in it....

    it should be the modulus (or percentage symbol)
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  14. #39
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup - it is the percentage symbol - I'd spotted that forum oddity a few posts ago.

    Before I mess with it too much, it looks like :

    PHP Code:
    //even row 
    if($row_count&#37;2==0) 

        
    $row_type 'even'

    //odd row 
    else 

        
    $row_type 'odd';             
    }
              
            echo(
    "<td><input "); 
            
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    "<td class=\"odd\">".$keywordData['Keyword'].'</td>'); 
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        echo(
    '</tr>'); 

    So that's seeing the CSS (either odd or even), but it's in the second <td> part slightly lower down.

    But if I change that line to :

    PHP Code:
    echo("<td class=\"".$row_type."\">".$keywordData['Keyword'].'</td>'); 
    It colours every <td> with the even colour.

    Adding in $row_count++; here alternates between categories, rather than rows within a category :

    PHP Code:
            echo('name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>'); 
            echo(
    "<td class=\"".$row_type."\">".$keywordData['Keyword'].'</td>'); 
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        
    $row_count++;
        echo(
    '</tr>'); 
    So it's probably close, just things not quite in the right places.

  15. #40
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I just clarify - do you want to alternate row colouring for each category or keyword? If it is each category, then ensure that you are only incrementing the counter when you move to a new category.
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  16. #41
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Increment the $row_count in this loop
    if($current_category <> $categoryData[2]['Category'])
    {
    //open a new <tr>
    echo "<tr>\n";
    //print the category as a header
    echo "<td colspan=\"8\">". $categoryData[2]['Category']."</td>\n";
    //close the <tr>
    echo "</tr>\n";
    $current_category = $categoryData[2]['Category'];
    //***INCREMENT HERE***
    $row_count ++:
    }
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  17. #42
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was to have the rows within each category alternating. I've changed it a bit to :

    PHP Code:
    //even row 
    if($row_count&#37;2==0) 

        
    $row_type 'even'

    //odd row 
    else 

        
    $row_type 'odd';             
    }

        echo(
    "<tr class=\"".$row_type."\">"); 
        foreach (
    $categoryData as $keywordData) { 
              

              
            echo(
    "<td><input "); 
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>');
            

             
            echo(
    "<td>".$keywordData['Keyword'].'</td>'); 
            
            
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        
        echo(
    '</tr>'); 


    $row_count++; 
    So it's doing the rows within the categories now - but haven't got the $row_count++; in the right place.

    Close as it all is now, its still doing some funny stuff that I mentioned in passing before - ie some of the checkbox / keyword "rows" are going to a new row before displaying 4.

    eg

    x keyword x keyword x keyword
    x keyword x keyword x keyword x keyword

  18. #43
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok - if you want to alternate the rows within each category - move the increment inside the while loop:

    PHP Code:
        echo('</tr>');
    }

    $row_count++; 
    becomes

    PHP Code:
        echo('</tr>');

        
    $row_count++;

    Can you post some HTML so we can see whats going on?
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  19. #44
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You probably want to initialise the counters with a value of 0 just before you start the while loop..

    ie $counter = 0;
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  20. #45
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code looking like :

    PHP Code:
    <table width="942px" border="0" cellpadding="0" cellspacing="0" align="center">
        <form name="form1" method="POST" action="photoKeywordsEdited.php">
    <input type='hidden' name='Photo_ID' value='<?php echo $Photo_ID?>'>
    <?php require_once('Connections/Photolibrary.php');
    error_reporting(E_ALL E_STRICT);
    $Photo_ID 1
    if (isset(
    $_GET['Photo_ID'])) { 
      
    $Photo_ID intval($_GET['Photo_ID']); 

    mysql_select_db($database_Photolibrary$Photolibrary); 
    $query_Keyword_Match sprintf("SELECT * FROM photokeywords WHERE Photo_ID = %s"$Photo_ID); 
    $Keyword_Match mysql_query($query_Keyword_Match$Photolibrary) or die(mysql_error()); 
    $photokeywords = array(); 
    while (
    $row_Keyword_Match mysql_fetch_assoc($Keyword_Match)) { 
        
    $photokeywords[] = $row_Keyword_Match['Keyword_ID']; 

    $totalRows_Keyword_Match mysql_num_rows($Keyword_Match); 
    $sql "SELECT * FROM Keywords ORDER BY Keyword_ID";
    $keywordArray = array(); 
    $query mysql_query($sql); 

    $row_count 0;

    while (
    $result=mysql_fetch_assoc($query)) { 
        
    $keywordArray[$result['Category']][] = $result

    $current_category ''

    foreach (
    $keywordArray as $categoryData


    if(
    $current_category <> $categoryData[2]['Category']) 
                { 
                    
    //open a new <tr> 
                    
    echo "<tr class=\"categorycell\">\n"
                    
    //print the category as a header 
                    
    echo "<td colspan=\"10\">"$categoryData[2]['Category']."</td>\n"
                    
    //close the <tr> 
                    
    echo "</tr>\n"
                    
    $current_category $categoryData[2]['Category'];

                }       


    //even row 
    if($row_count%2==0

        
    $row_type 'even'

    //odd row 
    else 

        
    $row_type 'odd';             
    }

        echo(
    "<tr class=\"".$row_type."\">"); 
        foreach (
    $categoryData as $keywordData) { 
              

              
            echo(
    "<td><input "); 
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>');
            

             
            echo(
    "<td>".$keywordData['Keyword'].'</td>'); 
            
            
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        
        echo(
    '</tr>'); 
        
    $row_count++;
    }
    is producing the HTML table :

    Code:
    <table width="942px" border="0" cellpadding="0" cellspacing="0" align="center">
    	<form name="form1" method="POST" action="photoKeywordsEdited.php">
    <input type='hidden' name='Photo_ID' value='145'>
    <tr class="categorycell">
    <td colspan="10">Places of Interest / buildings</td>
    </tr>
    <tr class="even"><td><input checked name="ckbox[2]" type="checkbox" class="tickbox2" id="ckbox[2]"></td><td>Ancient monument</td><td><input name="ckbox[3]" type="checkbox" class="tickbox2" id="ckbox[3]"></td><td>Aquarium</td><td><input name="ckbox[4]" type="checkbox" class="tickbox2" id="ckbox[4]"></td><td>Aqueduct / viaduct</td><td><input name="ckbox[5]" type="checkbox" class="tickbox2" id="ckbox[5]"></td><td>Bridge</td><td><input name="ckbox[6]" type="checkbox" class="tickbox2" id="ckbox[6]"></td><td>Castle / fort</td></tr><tr><td><input checked name="ckbox[7]" type="checkbox" class="tickbox2" id="ckbox[7]"></td><td>Country park</td><td><input name="ckbox[8]" type="checkbox" class="tickbox2" id="ckbox[8]"></td><td>Distillery</td><td><input name="ckbox[9]" type="checkbox" class="tickbox2" id="ckbox[9]"></td><td>Ecclesiastical building</td><td><input name="ckbox[10]" type="checkbox" class="tickbox2" id="ckbox[10]"></td><td>Exhibition centre / conference centre</td><td><input name="ckbox[11]" type="checkbox" class="tickbox2" id="ckbox[11]"></td><td>Garden / park / parkland</td></tr><tr><td><input name="ckbox[12]" type="checkbox" class="tickbox2" id="ckbox[12]"></td><td>Golf course</td><td><input name="ckbox[13]" type="checkbox" class="tickbox2" id="ckbox[13]"></td><td>Historic house</td><td><input name="ckbox[14]" type="checkbox" class="tickbox2" id="ckbox[14]"></td><td>Industrial building</td><td><input name="ckbox[15]" type="checkbox" class="tickbox2" id="ckbox[15]"></td><td>Lighthouse</td><td><input name="ckbox[16]" type="checkbox" class="tickbox2" id="ckbox[16]"></td><td>Model village</td></tr><tr><td><input name="ckbox[17]" type="checkbox" class="tickbox2" id="ckbox[17]"></td><td>Monument / memorial / grave / statue / fountain</td><td><input name="ckbox[18]" type="checkbox" class="tickbox2" id="ckbox[18]"></td><td>Museum / art gallery / heritage centre</td><td><input name="ckbox[19]" type="checkbox" class="tickbox2" id="ckbox[19]"></td><td>National park / forest park / regional park</td><td><input name="ckbox[20]" type="checkbox" class="tickbox2" id="ckbox[20]"></td><td>Notable building (other)</td><td><input name="ckbox[21]" type="checkbox" class="tickbox2" id="ckbox[21]"></td><td>Notable structure (other)</td></tr><tr><td><input name="ckbox[22]" type="checkbox" class="tickbox2" id="ckbox[22]"></td><td>Power station / wind farm</td><td><input name="ckbox[23]" type="checkbox" class="tickbox2" id="ckbox[23]"></td><td>Street scene</td><td><input name="ckbox[24]" type="checkbox" class="tickbox2" id="ckbox[24]"></td><td>Theatre / cinema / concert hall / opera house / art centre</td><td><input name="ckbox[25]" type="checkbox" class="tickbox2" id="ckbox[25]"></td><td>Theme park</td><td><input name="ckbox[26]" type="checkbox" class="tickbox2" id="ckbox[26]"></td><td>University / college</td></tr><tr><td><input name="ckbox[27]" type="checkbox" class="tickbox2" id="ckbox[27]"></td><td>Vineyard</td><td><input name="ckbox[28]" type="checkbox" class="tickbox2" id="ckbox[28]"></td><td>Visitor centre</td><td><input name="ckbox[29]" type="checkbox" class="tickbox2" id="ckbox[29]"></td><td>Water park</td><td><input name="ckbox[30]" type="checkbox" class="tickbox2" id="ckbox[30]"></td><td>Wildlife park / zoo / safari park / farm park</td></tr><tr class="categorycell">
    <td colspan="10">Activities / sports and crafts</td>
    </tr>
    <tr class="odd"><td><input name="ckbox[31]" type="checkbox" class="tickbox2" id="ckbox[31]"></td><td>Ball games</td></tr><tr><td><input name="ckbox[32]" type="checkbox" class="tickbox2" id="ckbox[32]"></td><td>Climbing / mountaineering</td><td><input name="ckbox[33]" type="checkbox" class="tickbox2" id="ckbox[33]"></td><td>Crafts</td><td><input name="ckbox[34]" type="checkbox" class="tickbox2" id="ckbox[34]"></td><td>Cycling</td><td><input name="ckbox[35]" type="checkbox" class="tickbox2" id="ckbox[35]"></td><td>Dancing</td><td><input name="ckbox[36]" type="checkbox" class="tickbox2" id="ckbox[36]"></td><td>Fishing</td></tr><tr><td><input name="ckbox[37]" type="checkbox" class="tickbox2" id="ckbox[37]"></td><td>Golf</td><td><input name="ckbox[38]" type="checkbox" class="tickbox2" id="ckbox[38]"></td><td>Horse riding / pony trekking</td><td><input name="ckbox[39]" type="checkbox" class="tickbox2" id="ckbox[39]"></td><td>Music</td><td><input name="ckbox[40]" type="checkbox" class="tickbox2" id="ckbox[40]"></td><td>Paragliding / hang gliding</td><td><input name="ckbox[41]" type="checkbox" class="tickbox2" id="ckbox[41]"></td><td>Sailing</td></tr><tr><td><input name="ckbox[42]" type="checkbox" class="tickbox2" id="ckbox[42]"></td><td>Shopping / shopping centre</td><td><input name="ckbox[43]" type="checkbox" class="tickbox2" id="ckbox[43]"></td><td>Skiing</td><td><input name="ckbox[44]" type="checkbox" class="tickbox2" id="ckbox[44]"></td><td>Swimming</td><td><input name="ckbox[45]" type="checkbox" class="tickbox2" id="ckbox[45]"></td><td>Walking / pathways</td><td><input name="ckbox[46]" type="checkbox" class="tickbox2" id="ckbox[46]"></td><td>Water sports</td></tr><tr></tr><tr class="categorycell">
    <td colspan="10">Physical features / landscapes</td>
    </tr>
    <tr class="even"><td><input name="ckbox[47]" type="checkbox" class="tickbox2" id="ckbox[47]"></td><td>Aerial view</td><td><input name="ckbox[48]" type="checkbox" class="tickbox2" id="ckbox[48]"></td><td>Beach / bay / cove</td><td><input name="ckbox[49]" type="checkbox" class="tickbox2" id="ckbox[49]"></td><td>Causeway</td><td><input name="ckbox[50]" type="checkbox" class="tickbox2" id="ckbox[50]"></td><td>Cave</td><td><input name="ckbox[51]" type="checkbox" class="tickbox2" id="ckbox[51]"></td><td>Cityscape</td></tr><tr><td><input name="ckbox[52]" type="checkbox" class="tickbox2" id="ckbox[52]"></td><td>Cliff</td><td><input name="ckbox[53]" type="checkbox" class="tickbox2" id="ckbox[53]"></td><td>Coast</td><td><input name="ckbox[54]" type="checkbox" class="tickbox2" id="ckbox[54]"></td><td>Crag / rock / tor</td><td><input name="ckbox[55]" type="checkbox" class="tickbox2" id="ckbox[55]"></td><td>Dune</td><td><input name="ckbox[56]" type="checkbox" class="tickbox2" id="ckbox[56]"></td><td>Estuary / marsh</td></tr><tr><td><input name="ckbox[57]" type="checkbox" class="tickbox2" id="ckbox[57]"></td><td>Farmland</td><td><input name="ckbox[58]" type="checkbox" class="tickbox2" id="ckbox[58]"></td><td>Forest / trees</td><td><input name="ckbox[59]" type="checkbox" class="tickbox2" id="ckbox[59]"></td><td>Hill</td><td><input name="ckbox[60]" type="checkbox" class="tickbox2" id="ckbox[60]"></td><td>Island</td><td><input name="ckbox[61]" type="checkbox" class="tickbox2" id="ckbox[61]"></td><td>Lake / loch / tarn / reservoir</td></tr><tr><td><input name="ckbox[62]" type="checkbox" class="tickbox2" id="ckbox[62]"></td><td>Landscapes (general)</td><td><input name="ckbox[63]" type="checkbox" class="tickbox2" id="ckbox[63]"></td><td>Lava</td><td><input name="ckbox[64]" type="checkbox" class="tickbox2" id="ckbox[64]"></td><td>Limestone pavement</td><td><input name="ckbox[65]" type="checkbox" class="tickbox2" id="ckbox[65]"></td><td>Moor / heathland</td><td><input name="ckbox[66]" type="checkbox" class="tickbox2" id="ckbox[66]"></td><td>Mountain</td></tr><tr><td><input name="ckbox[67]" type="checkbox" class="tickbox2" id="ckbox[67]"></td><td>Peninsula / headland</td><td><input checked name="ckbox[68]" type="checkbox" class="tickbox2" id="ckbox[68]"></td><td>River</td><td><input name="ckbox[69]" type="checkbox" class="tickbox2" id="ckbox[69]"></td><td>Sea / waves</td><td><input name="ckbox[70]" type="checkbox" class="tickbox2" id="ckbox[70]"></td><td>Valley / gorge / glen</td><td><input name="ckbox[71]" type="checkbox" class="tickbox2" id="ckbox[71]"></td><td>Waterfall</td></tr><tr></tr><tr class="categorycell">
    <td colspan="10">Events</td>
    </tr>
    <tr class="odd"><td><input name="ckbox[72]" type="checkbox" class="tickbox2" id="ckbox[72]"></td><td>Carnival</td><td><input name="ckbox[73]" type="checkbox" class="tickbox2" id="ckbox[73]"></td><td>Ceremony / pageantry</td><td><input name="ckbox[74]" type="checkbox" class="tickbox2" id="ckbox[74]"></td><td>Fair</td><td><input name="ckbox[75]" type="checkbox" class="tickbox2" id="ckbox[75]"></td><td>Flag / heraldry</td><td><input name="ckbox[76]" type="checkbox" class="tickbox2" id="ckbox[76]"></td><td>Festival</td></tr><tr><td><input name="ckbox[77]" type="checkbox" class="tickbox2" id="ckbox[77]"></td><td>Parade</td></tr><tr class="categorycell">
    <td colspan="10">Flora and fauna</td>
    </tr>
    <tr class="even"><td><input checked name="ckbox[78]" type="checkbox" class="tickbox2" id="ckbox[78]"></td><td>Bird</td><td><input name="ckbox[79]" type="checkbox" class="tickbox2" id="ckbox[79]"></td><td>Fish</td><td><input name="ckbox[80]" type="checkbox" class="tickbox2" id="ckbox[80]"></td><td>Flower / plant</td><td><input name="ckbox[81]" type="checkbox" class="tickbox2" id="ckbox[81]"></td><td>Insect</td></tr><tr><td><input name="ckbox[82]" type="checkbox" class="tickbox2" id="ckbox[82]"></td><td>Mammal</td><td><input name="ckbox[83]" type="checkbox" class="tickbox2" id="ckbox[83]"></td><td>Reptile</td><td><input name="ckbox[84]" type="checkbox" class="tickbox2" id="ckbox[84]"></td><td>Tree / shrub</td><td><input name="ckbox[85]" type="checkbox" class="tickbox2" id="ckbox[85]"></td><td>Amphibian</td><td><input name="ckbox[86]" type="checkbox" class="tickbox2" id="ckbox[86]"></td><td>Fungus</td></tr><tr></tr><tr class="categorycell">
    <td colspan="10">Transport and travel</td>
    </tr>
    <tr class="odd"><td><input name="ckbox[87]" type="checkbox" class="tickbox2" id="ckbox[87]"></td><td>Bus</td><td><input name="ckbox[88]" type="checkbox" class="tickbox2" id="ckbox[88]"></td><td>Canal</td><td><input name="ckbox[89]" type="checkbox" class="tickbox2" id="ckbox[89]"></td><td>Car / taxi</td><td><input name="ckbox[90]" type="checkbox" class="tickbox2" id="ckbox[90]"></td><td>Ship / boat / ferry / harbour</td><td><input name="ckbox[91]" type="checkbox" class="tickbox2" id="ckbox[91]"></td><td>Road / road sign</td></tr><tr><td><input name="ckbox[92]" type="checkbox" class="tickbox2" id="ckbox[92]"></td><td>Train / railway</td></tr><tr class="categorycell">
    <td colspan="10">Weather and seasons</td>
    </tr>
    <tr class="even"><td><input name="ckbox[93]" type="checkbox" class="tickbox2" id="ckbox[93]"></td><td>Autumn</td><td><input name="ckbox[94]" type="checkbox" class="tickbox2" id="ckbox[94]"></td><td>Bore</td><td><input name="ckbox[95]" type="checkbox" class="tickbox2" id="ckbox[95]"></td><td>Night</td><td><input name="ckbox[96]" type="checkbox" class="tickbox2" id="ckbox[96]"></td><td>Rain</td></tr><tr><td><input name="ckbox[97]" type="checkbox" class="tickbox2" id="ckbox[97]"></td><td>Sky / cloud</td><td><input name="ckbox[98]" type="checkbox" class="tickbox2" id="ckbox[98]"></td><td>Snow / ice</td><td><input name="ckbox[99]" type="checkbox" class="tickbox2" id="ckbox[99]"></td><td>Spring</td><td><input name="ckbox[100]" type="checkbox" class="tickbox2" id="ckbox[100]"></td><td>Summer</td><td><input checked name="ckbox[101]" type="checkbox" class="tickbox2" id="ckbox[101]"></td><td>Sunrise / sunset</td></tr><tr><td><input name="ckbox[102]" type="checkbox" class="tickbox2" id="ckbox[102]"></td><td>Winter</td></tr>
    </table>
    So is seeing the first row, but not counting - so I've got that in the wrong place.

    That also highlights what I was saying just now - if you look at the second category for example, it's starting a new row after 'Ball games', even tho' the next jeyword is still in the same category.

  21. #46
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you set the counter to be 1 instead of 0 when you initialise it - you should initialise both $counter and $row_counter = 1 outside of the while loop...

    Ideally this code:
    if ($counter==4) {
    echo('</tr><tr>');
    $counter = 0;
    } else {
    $counter++;
    }

    try the above setting to 1 and see if that helps at all.
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  22. #47
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry meant to say that :

    Ideally this code:
    if ($counter==4) {
    echo('</tr><tr>');
    $counter = 0;
    } else {
    $counter++;
    }

    you should use &#37; again instead of resetting the $counter to 0 when it reaches 4...
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  23. #48
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there - sorry I hadn't had a chance to look at this since Thursday.

    I presume from the above you were saying to change $counter = 0; to $counter = 1; ?

    With it as 0 the HTML is as above, with it changed to 1 it does change, but isn't displaying the alternate row colours :

    Code:
    <table width="942px" border="0" cellpadding="0" cellspacing="0" align="center">
    	<form name="form1" method="POST" action="photoKeywordsEdited.php">
    <input type='hidden' name='Photo_ID' value='151'>
    <tr class="categorycell">
    <td colspan="10">Places of Interest / buildings</td>
    </tr>
    <tr class="even"><td><input name="ckbox[2]" type="checkbox" class="tickbox2" id="ckbox[2]"></td><td>Ancient monument</td><td><input name="ckbox[3]" type="checkbox" class="tickbox2" id="ckbox[3]"></td><td>Aquarium</td><td><input name="ckbox[4]" type="checkbox" class="tickbox2" id="ckbox[4]"></td><td>Aqueduct / viaduct</td><td><input name="ckbox[5]" type="checkbox" class="tickbox2" id="ckbox[5]"></td><td>Bridge</td><td><input checked name="ckbox[6]" type="checkbox" class="tickbox2" id="ckbox[6]"></td><td>Castle / fort</td></tr><tr><td><input name="ckbox[7]" type="checkbox" class="tickbox2" id="ckbox[7]"></td><td>Country park</td><td><input name="ckbox[8]" type="checkbox" class="tickbox2" id="ckbox[8]"></td><td>Distillery</td><td><input name="ckbox[9]" type="checkbox" class="tickbox2" id="ckbox[9]"></td><td>Ecclesiastical building</td><td><input name="ckbox[10]" type="checkbox" class="tickbox2" id="ckbox[10]"></td><td>Exhibition centre / conference centre</td></tr><tr><td><input name="ckbox[11]" type="checkbox" class="tickbox2" id="ckbox[11]"></td><td>Garden / park / parkland</td><td><input name="ckbox[12]" type="checkbox" class="tickbox2" id="ckbox[12]"></td><td>Golf course</td><td><input name="ckbox[13]" type="checkbox" class="tickbox2" id="ckbox[13]"></td><td>Historic house</td><td><input name="ckbox[14]" type="checkbox" class="tickbox2" id="ckbox[14]"></td><td>Industrial building</td></tr><tr><td><input name="ckbox[15]" type="checkbox" class="tickbox2" id="ckbox[15]"></td><td>Lighthouse</td><td><input name="ckbox[16]" type="checkbox" class="tickbox2" id="ckbox[16]"></td><td>Model village</td><td><input name="ckbox[17]" type="checkbox" class="tickbox2" id="ckbox[17]"></td><td>Monument / memorial / grave / statue / fountain</td><td><input name="ckbox[18]" type="checkbox" class="tickbox2" id="ckbox[18]"></td><td>Museum / art gallery / heritage centre</td></tr><tr><td><input name="ckbox[19]" type="checkbox" class="tickbox2" id="ckbox[19]"></td><td>National park / forest park / regional park</td><td><input name="ckbox[20]" type="checkbox" class="tickbox2" id="ckbox[20]"></td><td>Notable building (other)</td><td><input name="ckbox[21]" type="checkbox" class="tickbox2" id="ckbox[21]"></td><td>Notable structure (other)</td><td><input name="ckbox[22]" type="checkbox" class="tickbox2" id="ckbox[22]"></td><td>Power station / wind farm</td></tr><tr><td><input name="ckbox[23]" type="checkbox" class="tickbox2" id="ckbox[23]"></td><td>Street scene</td><td><input name="ckbox[24]" type="checkbox" class="tickbox2" id="ckbox[24]"></td><td>Theatre / cinema / concert hall / opera house / art centre</td><td><input name="ckbox[25]" type="checkbox" class="tickbox2" id="ckbox[25]"></td><td>Theme park</td><td><input name="ckbox[26]" type="checkbox" class="tickbox2" id="ckbox[26]"></td><td>University / college</td></tr><tr><td><input name="ckbox[27]" type="checkbox" class="tickbox2" id="ckbox[27]"></td><td>Vineyard</td><td><input name="ckbox[28]" type="checkbox" class="tickbox2" id="ckbox[28]"></td><td>Visitor centre</td><td><input name="ckbox[29]" type="checkbox" class="tickbox2" id="ckbox[29]"></td><td>Water park</td><td><input name="ckbox[30]" type="checkbox" class="tickbox2" id="ckbox[30]"></td><td>Wildlife park / zoo / safari park / farm park</td></tr><tr></tr><tr class="categorycell">
    <td colspan="10">Activities / sports and crafts</td>
    </tr>
    <tr class="even"><td><input name="ckbox[31]" type="checkbox" class="tickbox2" id="ckbox[31]"></td><td>Ball games</td><td><input name="ckbox[32]" type="checkbox" class="tickbox2" id="ckbox[32]"></td><td>Climbing / mountaineering</td><td><input name="ckbox[33]" type="checkbox" class="tickbox2" id="ckbox[33]"></td><td>Crafts</td><td><input name="ckbox[34]" type="checkbox" class="tickbox2" id="ckbox[34]"></td><td>Cycling</td></tr><tr><td><input name="ckbox[35]" type="checkbox" class="tickbox2" id="ckbox[35]"></td><td>Dancing</td><td><input name="ckbox[36]" type="checkbox" class="tickbox2" id="ckbox[36]"></td><td>Fishing</td><td><input name="ckbox[37]" type="checkbox" class="tickbox2" id="ckbox[37]"></td><td>Golf</td><td><input name="ckbox[38]" type="checkbox" class="tickbox2" id="ckbox[38]"></td><td>Horse riding / pony trekking</td></tr><tr><td><input name="ckbox[39]" type="checkbox" class="tickbox2" id="ckbox[39]"></td><td>Music</td><td><input name="ckbox[40]" type="checkbox" class="tickbox2" id="ckbox[40]"></td><td>Paragliding / hang gliding</td><td><input name="ckbox[41]" type="checkbox" class="tickbox2" id="ckbox[41]"></td><td>Sailing</td><td><input name="ckbox[42]" type="checkbox" class="tickbox2" id="ckbox[42]"></td><td>Shopping / shopping centre</td></tr><tr><td><input name="ckbox[43]" type="checkbox" class="tickbox2" id="ckbox[43]"></td><td>Skiing</td><td><input name="ckbox[44]" type="checkbox" class="tickbox2" id="ckbox[44]"></td><td>Swimming</td><td><input name="ckbox[45]" type="checkbox" class="tickbox2" id="ckbox[45]"></td><td>Walking / pathways</td><td><input name="ckbox[46]" type="checkbox" class="tickbox2" id="ckbox[46]"></td><td>Water sports</td></tr><tr></tr><tr class="categorycell">
    <td colspan="10">Physical features / landscapes</td>
    </tr>
    <tr class="even"><td><input name="ckbox[47]" type="checkbox" class="tickbox2" id="ckbox[47]"></td><td>Aerial view</td><td><input name="ckbox[48]" type="checkbox" class="tickbox2" id="ckbox[48]"></td><td>Beach / bay / cove</td><td><input name="ckbox[49]" type="checkbox" class="tickbox2" id="ckbox[49]"></td><td>Causeway</td><td><input name="ckbox[50]" type="checkbox" class="tickbox2" id="ckbox[50]"></td><td>Cave</td></tr><tr><td><input name="ckbox[51]" type="checkbox" class="tickbox2" id="ckbox[51]"></td><td>Cityscape</td><td><input name="ckbox[52]" type="checkbox" class="tickbox2" id="ckbox[52]"></td><td>Cliff</td><td><input name="ckbox[53]" type="checkbox" class="tickbox2" id="ckbox[53]"></td><td>Coast</td><td><input name="ckbox[54]" type="checkbox" class="tickbox2" id="ckbox[54]"></td><td>Crag / rock / tor</td></tr><tr><td><input name="ckbox[55]" type="checkbox" class="tickbox2" id="ckbox[55]"></td><td>Dune</td><td><input name="ckbox[56]" type="checkbox" class="tickbox2" id="ckbox[56]"></td><td>Estuary / marsh</td><td><input name="ckbox[57]" type="checkbox" class="tickbox2" id="ckbox[57]"></td><td>Farmland</td><td><input name="ckbox[58]" type="checkbox" class="tickbox2" id="ckbox[58]"></td><td>Forest / trees</td></tr><tr><td><input name="ckbox[59]" type="checkbox" class="tickbox2" id="ckbox[59]"></td><td>Hill</td><td><input name="ckbox[60]" type="checkbox" class="tickbox2" id="ckbox[60]"></td><td>Island</td><td><input name="ckbox[61]" type="checkbox" class="tickbox2" id="ckbox[61]"></td><td>Lake / loch / tarn / reservoir</td><td><input name="ckbox[62]" type="checkbox" class="tickbox2" id="ckbox[62]"></td><td>Landscapes (general)</td></tr><tr><td><input name="ckbox[63]" type="checkbox" class="tickbox2" id="ckbox[63]"></td><td>Lava</td><td><input name="ckbox[64]" type="checkbox" class="tickbox2" id="ckbox[64]"></td><td>Limestone pavement</td><td><input name="ckbox[65]" type="checkbox" class="tickbox2" id="ckbox[65]"></td><td>Moor / heathland</td><td><input name="ckbox[66]" type="checkbox" class="tickbox2" id="ckbox[66]"></td><td>Mountain</td></tr><tr><td><input name="ckbox[67]" type="checkbox" class="tickbox2" id="ckbox[67]"></td><td>Peninsula / headland</td><td><input name="ckbox[68]" type="checkbox" class="tickbox2" id="ckbox[68]"></td><td>River</td><td><input name="ckbox[69]" type="checkbox" class="tickbox2" id="ckbox[69]"></td><td>Sea / waves</td><td><input name="ckbox[70]" type="checkbox" class="tickbox2" id="ckbox[70]"></td><td>Valley / gorge / glen</td></tr><tr><td><input name="ckbox[71]" type="checkbox" class="tickbox2" id="ckbox[71]"></td><td>Waterfall</td></tr><tr class="categorycell">
    <td colspan="10">Events</td>
    </tr>
    <tr class="even"><td><input name="ckbox[72]" type="checkbox" class="tickbox2" id="ckbox[72]"></td><td>Carnival</td><td><input name="ckbox[73]" type="checkbox" class="tickbox2" id="ckbox[73]"></td><td>Ceremony / pageantry</td><td><input name="ckbox[74]" type="checkbox" class="tickbox2" id="ckbox[74]"></td><td>Fair</td></tr><tr><td><input name="ckbox[75]" type="checkbox" class="tickbox2" id="ckbox[75]"></td><td>Flag / heraldry</td><td><input name="ckbox[76]" type="checkbox" class="tickbox2" id="ckbox[76]"></td><td>Festival</td><td><input name="ckbox[77]" type="checkbox" class="tickbox2" id="ckbox[77]"></td><td>Parade</td></tr><tr class="categorycell">
    <td colspan="10">Flora and fauna</td>
    </tr>
    <tr class="even"><td><input name="ckbox[78]" type="checkbox" class="tickbox2" id="ckbox[78]"></td><td>Bird</td></tr><tr><td><input name="ckbox[79]" type="checkbox" class="tickbox2" id="ckbox[79]"></td><td>Fish</td><td><input name="ckbox[80]" type="checkbox" class="tickbox2" id="ckbox[80]"></td><td>Flower / plant</td><td><input name="ckbox[81]" type="checkbox" class="tickbox2" id="ckbox[81]"></td><td>Insect</td><td><input name="ckbox[82]" type="checkbox" class="tickbox2" id="ckbox[82]"></td><td>Mammal</td></tr><tr><td><input name="ckbox[83]" type="checkbox" class="tickbox2" id="ckbox[83]"></td><td>Reptile</td><td><input name="ckbox[84]" type="checkbox" class="tickbox2" id="ckbox[84]"></td><td>Tree / shrub</td><td><input name="ckbox[85]" type="checkbox" class="tickbox2" id="ckbox[85]"></td><td>Amphibian</td><td><input name="ckbox[86]" type="checkbox" class="tickbox2" id="ckbox[86]"></td><td>Fungus</td></tr><tr></tr><tr class="categorycell">
    <td colspan="10">Transport and travel</td>
    </tr>
    <tr class="even"><td><input name="ckbox[87]" type="checkbox" class="tickbox2" id="ckbox[87]"></td><td>Bus</td><td><input name="ckbox[88]" type="checkbox" class="tickbox2" id="ckbox[88]"></td><td>Canal</td><td><input name="ckbox[89]" type="checkbox" class="tickbox2" id="ckbox[89]"></td><td>Car / taxi</td><td><input name="ckbox[90]" type="checkbox" class="tickbox2" id="ckbox[90]"></td><td>Ship / boat / ferry / harbour</td></tr><tr><td><input name="ckbox[91]" type="checkbox" class="tickbox2" id="ckbox[91]"></td><td>Road / road sign</td><td><input name="ckbox[92]" type="checkbox" class="tickbox2" id="ckbox[92]"></td><td>Train / railway</td></tr><tr class="categorycell">
    <td colspan="10">Weather and seasons</td>
    </tr>
    <tr class="even"><td><input name="ckbox[93]" type="checkbox" class="tickbox2" id="ckbox[93]"></td><td>Autumn</td><td><input name="ckbox[94]" type="checkbox" class="tickbox2" id="ckbox[94]"></td><td>Bore</td></tr><tr><td><input name="ckbox[95]" type="checkbox" class="tickbox2" id="ckbox[95]"></td><td>Night</td><td><input name="ckbox[96]" type="checkbox" class="tickbox2" id="ckbox[96]"></td><td>Rain</td><td><input name="ckbox[97]" type="checkbox" class="tickbox2" id="ckbox[97]"></td><td>Sky / cloud</td><td><input name="ckbox[98]" type="checkbox" class="tickbox2" id="ckbox[98]"></td><td>Snow / ice</td></tr><tr><td><input name="ckbox[99]" type="checkbox" class="tickbox2" id="ckbox[99]"></td><td>Spring</td><td><input checked name="ckbox[100]" type="checkbox" class="tickbox2" id="ckbox[100]"></td><td>Summer</td><td><input name="ckbox[101]" type="checkbox" class="tickbox2" id="ckbox[101]"></td><td>Sunrise / sunset</td><td><input name="ckbox[102]" type="checkbox" class="tickbox2" id="ckbox[102]"></td><td>Winter</td></tr><tr></tr>
    </table>
    <table>
      <tr>
      <td>
      <input type="submit" name="Submit" value="Update Photo Keywords">
      <input type="reset" name="Reset" value="Reset form">
      </form></td>
    
    	</tr>
    	
    </table>
    In this one the spacings of the columns aren't so good - the fisrst four a bit larger, leaving no room for the fifth - except in the 'Places of Interest' catergory, which squeezes in :

    x castle /
    fort

    But none of the othere rows have a fifth column, and there are still premature new rows after the keywords :

    'Fair' (Events)
    'Bird' (Flora and fauna) and
    'Bore' (Weather and seasons)

    If that makes sense?

  24. #49
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the code that's pretty much there :

    PHP Code:
    <form name="form1" method="POST" action="photoKeywordsEdited.php">
    <input type='hidden' name='Photo_ID' value='<?php echo $Photo_ID?>'>
    <?php require_once('Connections/Photolibrary.php');
    error_reporting(E_ALL E_STRICT);
    $Photo_ID 1
    if (isset(
    $_GET['Photo_ID'])) { 
      
    $Photo_ID intval($_GET['Photo_ID']); 

    mysql_select_db($database_Photolibrary$Photolibrary); 
    $query_Keyword_Match sprintf("SELECT * FROM photokeywords WHERE Photo_ID = %s"$Photo_ID); 
    $Keyword_Match mysql_query($query_Keyword_Match$Photolibrary) or die(mysql_error()); 
    $photokeywords = array(); 
    while (
    $row_Keyword_Match mysql_fetch_assoc($Keyword_Match)) { 
        
    $photokeywords[] = $row_Keyword_Match['Keyword_ID']; 

    $totalRows_Keyword_Match mysql_num_rows($Keyword_Match); 
    $sql "SELECT * FROM Keywords ORDER BY Keyword_ID";
    $keywordArray = array(); 
    $query mysql_query($sql); 



    while (
    $result=mysql_fetch_assoc($query)) { 
        
    $keywordArray[$result['Category']][] = $result

    $current_category ''

    foreach (
    $keywordArray as $categoryData


    if(
    $current_category <> $categoryData[2]['Category']) 
                { 
                    
    //open a new <tr> 
                    
    echo "<tr class=\"categorycell\">\n"
                    
    //print the category as a header 
                    
    echo "<td colspan=\"10\">"$categoryData[2]['Category']."</td>\n"
                    
    //close the <tr> 
                    
    echo "</tr>\n"
                    
    $current_category $categoryData[2]['Category'];

                }       

    $row_count 0;
    //even row 
    if($row_count%2==0

        
    $row_type 'even'

    //odd row 
    else 

        
    $row_type 'odd';             
    }

        echo(
    "<tr class=\"".$row_type."\">"); 
        foreach (
    $categoryData as $keywordData) { 
              

              
            echo(
    "<td><input "); 
            if (
    in_array($keywordData['Keyword_ID'],$photokeywords)) { 
                echo 
    "checked "
            } 
            echo(
    'name="ckbox['.$keywordData['Keyword_ID'].']" type="checkbox" class="tickbox2" id="ckbox['.$keywordData['Keyword_ID'].']"></td>');
            

             
            echo(
    "<td>".$keywordData['Keyword'].'</td>'); 
            

            
            if (
    $counter==4) { 
                echo(
    '</tr><tr>'); 
                
    $counter 0
            } else { 
                
    $counter++; 
            } 
        } 
        
        echo(
    '</tr>'); 
        
    $row_count++;




    ?>
    I'm having trouble modifying it for my original Add Keywords page - basically there's a previous page that collects the photo info for the photos table, then the user is directed to the add keywords page (so previously the Photo_ID) was passed through as a hidden field :

    PHP Code:
    <input type='hidden' name='Photo_ID' value='<!--FIELDVALUE:Photo_ID-->'
    As I'm still a bit unfamiliar with the syntax for arrays, what exactly needs changing in the above code to adapt it to the Add keywords page?

    Hope that makes sense.

    Cheers,
    Iain

  25. #50
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which file is the above code from?

    Can you post the code for the 2 files so I can see what the flow is?

    Thx
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •