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