Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8436893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:18:15+00:00 2026-06-10T07:18:15+00:00

I have mysql set up like this MySQL Table: gallery +————-+————+ | galleryname |

  • 0

I have mysql set up like this

MySQL

Table: gallery

+-------------+------------+
| galleryname | coverphoto |
+-------------+------------+

Table: multigalleries

+-------------+-----------+
| galleryname | galleries |
+-------------+-----------+

I am using a checkbox array from php to place galleries into multigalleries.galleries like gallery1,gallery2,gallery3. All of that works fine, the only thing i cant figure out is, when I pull the list of gallery.galleryname and reference it with multigalleries.galleries, how can i return a checked state if it exists in multigalleries.galleries?

Any help would be greatly appreciated.

EDIT// ACTUAL CODE IM USING IF IT WILL HELP

$con = mysql_connect($host,$dbusername,$dbpassword);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($databasename, $con);
$query = "SELECT galleries.gallery, galleries.coverphoto, multigalleries.multigallery,            multigalleries.galleries FROM galleries, multigalleries";
$result = mysql_query($query);

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '<div class="gallery" style="background-image:none">';
echo '<input type="checkbox" name="galleriesm[]" value="'.$line.'">'.      $line.'';
echo '</div>';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:18:16+00:00Added an answer on June 10, 2026 at 7:18 am

    Try this:

    $a = mysql_query("
        SELECT g.galleryname FROM gallery AS g, multigalleries AS m
        WHERE g.galleryname = 'gallery1' AND FIND_IN_SET(g.galleryname, m.galleries)
    ");
    
    $b = mysql_fetch_assoc($a);
    
    echo '<input type="checkbox" name="whatever"';
    
    if($b['galleryname'])
    {
        echo ' checked="checked"';
    }
    
    echo '>';
    

    Edit:

    $result = mysql_query("
        SELECT g.galleryname, m.galleryname AS name FROM gallery AS g 
        LEFT JOIN (SELECT galleryname, galleries FROM multigalleries) AS m ON 
        FIND_IN_SET(g.galleryname, m.galleries)
    ");
    
    while($row = mysql_fetch_assoc($result))
    {
        $checked = '';
    
        if($row['name'])
        {
            $checked = ' checked="checked"';
        }
    
        echo '<input type="checkbox" name="galleriesm[]" id="'.$row['galleryname'].'" value="'.$row['galleryname'].'"'.$checked.'>
        <label for="'.$row['galleryname'].'">'.$row['galleryname'].'</label>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL query that looks like this: UPDATE `Table` SET `Column` =
I have a mysql table set up like this id | refference_id | data
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have a mysql table like this (sql): CREATE TABLE IF NOT EXISTS silver_and_pgm
I have a MySQL table for storing details of uploaded files, like this: CREATE
I have a MySQL table like this one: day int(11) hour int(11) amount int(11)
Suppose I have a simple MySQL table that looks like this: CREATE TABLE `my_table`
I have a MySQL table which contains comma-separated values like this: first row=(3,56,78,12) second
Suppose I have a table (MySQL) like this: CREATE TABLE sessions ( session_id INT
I have a MySQL table laid out like this: ID | Artist | Title

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.