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

  • Home
  • SEARCH
  • 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 8107299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:43:26+00:00 2026-06-06T00:43:26+00:00

I have a MySQL database with 3 tables: **articles:** id – articletitle – articleorganization

  • 0

I have a MySQL database with 3 tables:

**articles:**

id - articletitle - articleorganization - articleurl - articledate

**tags:**

id - articletag

articles_tags

**id:**
article_id - tag_id

On my form I have text input boxes to fill in the information for Title, Organization, URL, and Date and I have checkboxes to capture Tag information.

This works very well but the problem comes when I need to edit an entry in the database. With that I have a similar form to the entry form but I can’t get the checkboxes to work. After some research and much help from Stackoverflow contributors, I’ve learned that what I need is a different type of database structure (which is what I now have, I originally only had 1 table, now I have the 3 listed above).

This leads me to redeveloping the entry form so now I am attempting to insert the Title, Organization, URL, and Date information into into the articles table and the Tag information into the tags table while also creating a relationship in the articles_tags table.

So far I’ve been unsuccessful in this attempt. Here is what I’ve been working with so far:

    <?php
     function renderForm($articletitle, $articleorganization, $articledate, $articleurl, $articletags )
     {
     ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    . . .
    </head>

    <body>

    <div class="container">
      <div class="header">
      . . .
      </div>
        <div class="sidebar1">
        . . .
        </div>
      <div class="content">
            <div id="stylized" class="myform">
          <form id="form" name="form" action="" method="post">
            <h1>Create a new entry in the database</h1>
            <table width="100%" border="0" cellpadding="6">
              <tr>
                <td colspan="2"><legend>Article details</legend></td>
              </tr>
              <tr>
                <td width="20%" align="right"><span class="field">Article Title:</span></td>
                <td width="80%" align="left"><span class="field">
                  <input name="articletitle" type="text" value="<?php echo $articletitle; ?>" size="50"/>
                </span></td>
              </tr>
              <tr>
                <td align="right"><span class="field">Article Author:</span></td>
                <td align="left"><span class="field">
                  <input name="articleorganization" type="text" value="<?php echo $articleorganization; ?>" size="50"/>
                </span></td>
              </tr>
              <tr>
                <td align="right"><span class="field">Access Date:</span></td>
                <td align="left"><span class="field">
                  <input name="articledate" type="text" value="MM/DD/YYYY" size="50"/>
                </span></td>
              </tr>
              <tr>
                <td align="right"><span class="field">Article URL:</span></td>
                <td align="left"><span class="field">
                <input name="articleurl" type="text" value="<?php echo $articleurl; ?>" size="50"/>
                </span></td>
              </tr>
              <tr>
                <td align="right"><span class="field">Article Tags:</span></td>
                <td align="left"><span class="field">
                        <input type="checkbox" name="articletags[]" value="geology" id="articletags_0" />
                        <input type="checkbox" name="articletags[]" value="astronomy" id="articletags_1" />
                </span></td>
              </tr>
            </table>
            <footer><input type="submit" name="submit" value="Add this Article"></footer>
            </form>
        </div>
      <div class="footer">
        . . .
        </div>
    </body>
    </html>
    <?php 
     }

     include('settings.php');

     if(count($articletags) > 0)
    {
     $articletags_string = implode(",", $articletags);
    }

     if($_SERVER['REQUEST_METHOD'] == 'POST')
    { 

     $articletitle = mysql_real_escape_string(htmlspecialchars($_POST['articletitle']));
     $articleorganization = mysql_real_escape_string(htmlspecialchars($_POST['articleorganization']));
     $articledate = mysql_real_escape_string(htmlspecialchars($_POST['articledate']));
     $articleurl = mysql_real_escape_string(htmlspecialchars($_POST['articleurl']));
     $articletags = implode(',', $_POST['articletags']);

     mysql_query("INSERT articles SET articletitle='$articletitle',
          articleorganization='$articleorganization',
          articledate='$articledate',
          articleurl='$articleurl',
          articletags='$articletags' ")

    mysql_query2("INSERT tags SET articletags='$articletags' ")


     header("Location:addsuccess.php"); 
     }
     }
     else

     {
     renderForm('','','','','');
     }
    ?>
  • 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-06T00:43:28+00:00Added an answer on June 6, 2026 at 12:43 am

    You are missing a keyword INTO in your SQL queries – INSERT INTO mytable…
    You can also merge the last 2 tables into one – “tag_id, article_id, article_tags”.
    And one advice – please read what PDO is and get rid of mysql_*.

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

Sidebar

Related Questions

I have a MySQL database with 3 tables: articles, tags, and articles_tags The schema
i have a question about basic mysql database optimisation. I have 3 tables, Articles,
I currently have a very simple MySQL database (articlesDB) with 1 table (articles) and
I have a MySQL database with multiple tables, each of which have the same
I have a MySQL database with 60 tables. Most of the tables have primary
Suppose I am building an app using current mysql database tables. I have this
I have a MySQL database with a few (five to be precise) huge tables.
I have a MySQL database set-up in a hierarchy style. There are 4 tables
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
I have 5 tables in my Mysql database with t1 with field name like

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.