Jump to content

Checkbox question - editing an existing selection


BarneyJoe

Recommended Posts

What it is, is...

I have a table photos, and a table keywords, whereby keywords can be attached to each photo, using a table photokeywords.

This works fine when adding the keywords, using a page of checkboxes for each keyword.

I'm just working on a page where people can edit the list of keywords for any given photo.

I think it's almost working, but I'm still missing something. At the moment only the first matching checkbox is appearing as checked.

The code is currently :

[code]<?php require_once('Connections/Photolibrary.php'); ?>
<?php
$colname_Keyword_Match = "1";
if (isset($_GET['Photo_ID'])) {
  $colname_Keyword_Match = (get_magic_quotes_gpc()) ? $_GET['Photo_ID'] : addslashes($_GET['Photo_ID']);
}
mysql_select_db($database_Photolibrary, $Photolibrary);
$query_Keyword_Match = sprintf("SELECT * FROM photokeywords WHERE Photo_ID = %s", $colname_Keyword_Match);
$Keyword_Match = mysql_query($query_Keyword_Match, $Photolibrary) or die(mysql_error());
$row_Keyword_Match = mysql_fetch_assoc($Keyword_Match);
$totalRows_Keyword_Match = mysql_num_rows($Keyword_Match);

$Photo_ID = intval($_GET['Photo_ID']);

?>[/code]

And then for each checkbox :

[code]<input <?php if (!(strcmp($row_Keyword_Match['Keyword_ID'],2))) {echo "checked";} ?> name="ckbox[2]" type="checkbox" class="tickbox2" id="ckbox[2]">

etc[/code]

What am I missing?

Cheers,
Iain

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.