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.
Bookmarks