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 692333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:38:23+00:00 2026-05-14T02:38:23+00:00

I have a table column called post_tags within a table called posts where assigned

  • 0

I have a table column called post_tags within a table called posts where assigned tags are stored separated by the @ symbol. I also have a table called tags where all tag names are stored. I would like to design my database in a more normalized way but for the purpose I am trying to achieve this is the easiest option.

Anyway, I want to display on the screen all the entries from the tags table as checkboxes, so I do:

    $query = mysql_query("SELECT * FROM tags ORDER BY name");

    while ($row = mysql_fetch_assoc($query)) {

        $tag = $row['name'];

        echo "<input type='checkbox' name='tags[]' value='$tag' />\n";

    }

Next I want to have the tags that are assigned to a particular post be preselected. For example, if I have a post with the following in it’s post_tags column:

party@beaches@dolphins@

I want the “party”, “beaches” and “dolphin” checkboxes to be checked by default (while the checkboxes for the other options are unchecked). How can this be done?

  • 1 1 Answer
  • 1 View
  • 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-05-14T02:38:23+00:00Added an answer on May 14, 2026 at 2:38 am

    The first thing to do is see if there is any existing data. So run that query and put the result of that table cell into lets say $checkedstring if not then put your default string in.

    <?php
    $checkedstring = "party@beaches@dolphins@";
    //Pull from DB if exsists and set $checkedstring to that value
    ///
    $checkeditems =  explode ( "@" , $checkedstring);
    $checked = array();
    foreach($checkeditems as $item)
    {
      $checked[$item]=true;
    }    
    
    $query = mysql_query("SELECT * FROM tags ORDER BY name");
    
    while ($row = mysql_fetch_assoc($query)) 
    {
        $tag = $row['name'];
        $checkedstatus = '';
        if($checked[$tag])
        {
          $checkedstatus = "checked='checked'";
        }
        echo "<input type='checkbox' name='tags[]' value='$tag' $checkedstatus />\n";
    }
    
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table with a column called 'symbol', that is unique via
I have a database table called Posts which stores all the information regarding an
I have a table with a column called time, HH:MM:SS. How can I do
If I have table with a Date column called myDate , with values like
I have a value in my MS SQL table column called XDATA like this:
In database table I have column called options . It has type of integer
I have a table that has a certain numeric column called Score . I
I have a table which has a column called Direct of type char(1). It's
I have a table in MYSQL with a column called league. When I try
I have a table called scheduler_sched which has several columns, including a column called

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.