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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:00:04+00:00 2026-06-18T04:00:04+00:00

I want to create a table for documents and allow users to select whether

  • 0

I want to create a table for documents and allow users to select whether the document is required or not in relation to a task. I need it to check the current status of the document to see if it is already required and if it is mark the tick box as checked. There are currently 4 documents in the database and only 2 associations to 2 of the documents for this particular task.

When there is no association of a document to a task there will be no entry in the database to say that it is not associated it just simple will not be in that table.

The code I have currently will show checkboxes against those 2 documents which have associations however do not show any tick boxes at all for the ones that have no association. I would like it to still show the 3 check boxes, so that the user can change its association, but as default it should check not required. Currently It just shows no tick boxes at all. Below is the PHP snip. Please advise if you would like a screenshot or the DB dumps.

Any help would be greatly appreciated. I’m hoping its just been a long day and I am forgetting something simple.

    <table border=1>
      <tr>
        <td align=center><p>Here you can associate documents to Jobs and Tasks to.</p> </td>
      </tr>
    </table>';



$order2 = "SELECT * FROM documents";
$result2 = mysql_query($order2);
while ($row2 = mysql_fetch_array($result2)) {

$nice_name = $row2['nice_name'];
$doc_id = $row2['id'];

}

echo '
<h3>Documents</h3>

    <table border=1>
      <tr><th>Document Name</th><th>Document Type</th><th>Required</th><th>Optional</th><th>Not Required</th></tr>
    ';



$order2 = "SELECT * FROM documents ORDER BY type_id";
$result2 = mysql_query($order2);
while ($row2 = mysql_fetch_array($result2)) {

$nice_name = $row2['nice_name'];
$doc_id = $row2['id'];
$doc_type_id = $row2['type_id'];

echo '

      <tr>
        <td>'.$nice_name.'</td>';

$order3 = "SELECT * FROM document_types WHERE id = '$doc_type_id'";
$result3 = mysql_query($order3);
while ($row3 = mysql_fetch_array($result3)) {

$type_name = $row3['type_name'];

    echo '
        <td>'.$type_name.'</td>';

$order4 = "SELECT * FROM document_assoc WHERE doc_id = '$doc_id'";
$result4 = mysql_query($order4);
while ($row4 = mysql_fetch_array($result4)) {

$requirement = $row4['requirement'];

    echo '

        <td><input type="checkbox" name="req" value="2" '; if ($requirement == 2) { echo ' checked '; } echo '></td>
        <td><input type="checkbox" name="opt" value="1" '; if ($requirement == 1) { echo ' checked '; } echo '></td>
        <td><input type="checkbox" name="not" value="0" '; if ($requirement < 1) { echo ' checked '; } echo '></td>';
    }

    }

    echo '
      </tr>';
    }
    echo '
    </table>';

So far I have just tried tweaking the requirement = with the final tick box. But as it is staying the same whether i use NULL ect – im guessing im missing something.

Kind Regards,

n00bstacker

  • 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-18T04:00:06+00:00Added an answer on June 18, 2026 at 4:00 am

    You can use the following if statement to identify the situation and respond appropriately:

                $order4 = "SELECT * FROM document_assoc WHERE doc_id = '$doc_id'";
                    $result4 = mysql_query($order4);
                    $_results = mysql_fetch_array($result4);
                    if (!$_results) {
                           <<<< OUTPUT THE CHECKBOXES/INPUTS YOU NEED >>>>
                    } else {
                       foreach ($_results as $result) {
    
                    $requirement = $result['requirement'];
    
    echo '
    
        <td><input type="checkbox" name="req" value="2" '; if ($requirement == 2) { echo ' checked '; } echo '></td>
        <td><input type="checkbox" name="opt" value="1" '; if ($requirement == 1) { echo ' checked '; } echo '></td>
        <td><input type="checkbox" name="not" value="0" '; if ($requirement < 1) { echo ' checked '; } echo '></td>';
    }
    
    }
    

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create JSF table which has select all button and check box
These are my 2 tables: CREATE TABLE `documents` ( `Document_ID` int(10) NOT NULL auto_increment,
I have a MySQL table: CREATE TABLE documents ( id INT NOT NULL AUTO_INCREMENT,
Can someone double-check my trimmed-down example? When the Documents table is updated, I want
I want to create a table that is fully contained within its parent element,
I want to create a table of friends with personal information and log on
I want to create a table like myTable = { [0] = { [a]
I want to create a table in MS SQL Server 2005 to record details
I want to create a table structure with checkbox for each row and each
i want to create a table : products which looks like (these are columns

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.