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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:18:14+00:00 2026-06-16T00:18:14+00:00

I have two tables, categories and info. categories looks like: id | name info

  • 0

I have two tables, categories and info.

categories looks like:

id | name 

info looks like:

id | parent_id | name | url

parent_id is the id from categories.

I have a form where a user can add more than one url. There is a button that can be pressed to make more url fields appear. If there is more than one url, then url2, url3, etc are added to the database.

info will then look like:

id | parent_id | name | url | url2 | url3

Is this an appropriate approach?

If so, what if info is like this:

id | parent_id |name  |url            |url2          |url3
1  | 1         |One   |http://cnn.com |
2  | 1         |Two   |http://msn.com |http://aol.com|

When I view One or Two or w/e, how do I query to get their urls?

I know I can do:

$mysqli->query("SELECT i.url FROM info AS i LEFT JOIN categories AS c ON i.parent_id = c.id");

But this is dependent on me putting i.url, i.url2, i.url3 and I would have to create a separate query for each info. I want it so PHP determines how many and what i.url to select.

So it should be:

$mysqli->query("SELECT (PHP determines what i.url to put here depending on what info page I'm viewing) FROM info AS i LEFT JOIN categories AS c ON i.parent_id = c.id");
  • 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-16T00:18:14+00:00Added an answer on June 16, 2026 at 12:18 am

    If you go that path you will have a bunch of columns with null values and encounter issues with queries, which is pretty much what you are describing.

    I would create a different table (perhaps urls) that maps info with urls. For example:

    url_id | info_id | url 
    

    This is the Repeated Attributes design pattern which is concisely explained here:
    http://www.tomjewett.com/dbdesign/dbdesign.php?page=phone.php

    Here is an example on how to query:

    SELECT i.*, url
    FROM info i JOIN urls u ON i.id = u.info_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Two tables like this: Table categories: columns: id, name, parent 1, Foods,
I have two tables: parent-child 'categories': id name parent_id 1 Food NULL 2 Pizza
I have two tables user table user_id | name | 1 | peter |
I have two tables namely 'categories' & 'products' as follows: categories id | name
i have two tables Table1 : Categories , Columns : id , parent_id ,
I have two tables as such: Categories: ID - Name - Desc Items ID
I have two tables ITEMS : id, name CATEGORIES: items_id, category I need to
I have two tables, omc_categories and omc_products. I want to pull out categories name
I have two tables, Categories and RecipeCategories **Categories** CategoryID varchar (Primary Key) Name varchar
I have two tables. The name table have a foreign key named 'categories'. The

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.