# Is it possible to post two separate values when an item is selected with the Select option?

**URL:** <https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025>\
**Category:** Beginners - Learning PHP\
**Created:** [September 23, 2022, 8:28am UTC](https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025 "2022-09-23T08:28:23Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Adem](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Adem](https://www.phphelp.com/u/Adem)\
**Post date:** [October 14, 2022, 2:04pm UTC](https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025/21 "2022-10-14T14:04:34Z")

</div>

I solved the problem as below

```auto
IFNULL(CONCAT(p.input_id,'X',p.output_id,' '),'')

```

---

<div class="post-metadata">

**Author:** ![Adem](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Adem](https://www.phphelp.com/u/Adem)\
**Post date:** [October 14, 2022, 8:06pm UTC](https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025/22 "2022-10-14T20:06:54Z")

</div>

now i have another problem  
I collect properties of all products in “product\_types” table

 ![Ekran görüntüsü 2022-10-14 225309](https://www.phphelp.com/uploads/default/original/2X/4/4b46f7e71849362074b11a9a9f2e2170ec9cd8ac.png)  
some columns are null by product, A section is visible in the example image

```auto
$sql = "SELECT c.name, p.id, 
CONCAT(
IFNULL(CONCAT(p.input_id,'X',p.output_id,' '),''),
IFNULL(CONCAT(p.product_type_id,' '),''),
b.name,' ',
p.name
) b_p_name
  FROM products p
  INNER JOIN brands b ON p.brand_id = b.id
  INNER JOIN product_categories c ON p.category_id = c.id
  WHERE p.product_stock=? AND b.brand_active=?
  ORDER BY c.name, b.name, p.name";

```

i think this is what i have to do

```auto
INNER JOIN product_types pt ON p.input_id = pt.id
INNER JOIN product_types pt ON p.output_id = pt.id
INNER JOIN product_types pt ON p.product_type_id = pt.id

```

I guess I need to do something like this, but it doesn’t work. How should I do INNER JOIN with more than one column of a table?

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [October 15, 2022, 6:32am UTC](https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025/23 "2022-10-15T06:32:41Z")

</div>

Databases are not speadsheets. You should only store data that exists. That table should have one row for each separate piece of product/property data.

---

<div class="post-metadata">

**Author:** ![Adem](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Adem](https://www.phphelp.com/u/Adem)\
**Post date:** [October 15, 2022, 9:05am UTC](https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025/24 "2022-10-15T09:05:05Z")

</div>

I solved this problem by using LEFT JOIN instead of INNER JOIN but another problem appeared

Example output\_type, multiple products are using this column name.  
Output type name appeared in unrelated products because I used output\_type column name in CONCAT()

Even if I collect the Product Types in a table, each product’s type, feature, etc. columns will be separate.  
You’re saying that no column will be common, right?

For each product. Do I create a separate table for its type, property, etc. or do I create them all in one table? What is your suggestion?

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [October 15, 2022, 3:41pm UTC](https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025/25 "2022-10-15T15:41:22Z")

</div>

You would have one product\_type(s) table. It would have columns for -

1. an id (which you apparently have)
2. product\_id (which you apparently have)
3. type (which would be whatever the existing column names are)
4. value (which would be whatever the existing stored values are)

---

<div class="post-metadata">

**Author:** ![Adem](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Adem](https://www.phphelp.com/u/Adem)\
**Post date:** [October 17, 2022, 7:27am UTC](https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025/26 "2022-10-17T07:27:00Z")

</div>

For each product separately, I have a table of product type, property etc.

 ![Ekran görüntüsü 2022-10-17 094958](https://www.phphelp.com/uploads/default/original/2X/a/a9b2090630344324389fd55a52a678015078bab3.png)

![Ekran görüntüsü 2022-10-17 095021](https://www.phphelp.com/uploads/default/original/2X/8/8a2cbfe27ede3bfe1a5d2a9896d595620904deb0.png)

 ![Ekran görüntüsü 2022-10-17 095041](https://www.phphelp.com/uploads/default/original/2X/b/b611aef461f31681df3d8ce415c77c90b3541846.png)

 ![Ekran görüntüsü 2022-10-17 095119](https://www.phphelp.com/uploads/default/original/2X/1/1f984747a7d3b845e750afbc528c7c8e3517a379.png)

Since I have gathered all the products in a single table, Is it correct to tap into a single table for product type, properties, etc.?

It is necessary to create a separate column for each product type.  
`ID | a_product_type | b_product_type | c_product_type | c_product_type | ....`  
This means that there will be close to 100 columns in a table in this format.

I used a “product\_type” column in the “product\_types” table for all products. The table below is shown in the picture

 ![Ekran görüntüsü 2022-10-17 095237](https://www.phphelp.com/uploads/default/original/2X/3/37be73f91cb5e5c8896a30d94b7ead64ed0f6ba9.png)  
The problems shown in the picture below appear  
Product type that does not belong to the product appears  
 ![Ekran görüntüsü 2022-10-17 101010](https://www.phphelp.com/uploads/default/original/2X/e/e8718ad5ba8f668955a3f9b8072fbd858fded7af.png)

The problem in the picture below is this.  
`input_name | output_name |` there are columns  
I used below query to show like 17X8, 17X12, 17X16  
`IFNULL(CONCAT(t.input_name,'X',t.output_name,' '),'')`  
I also used the following query for just the output of another product  
`IFNULL(CONCAT(,t.output_name,' '),''),`  
As seen in the picture below, these products should not have underlined data in the problem, but they are visible.  
This is because all products use the same column.  
Is there a solution to this?  
Or should I make separate columns for each product type? This means that there will be close to 100 columns in a table, is this the right way?

 ![Ekran görüntüsü 2022-10-17 101208](https://www.phphelp.com/uploads/default/original/2X/a/aa9dc64aef2d5d8c6c8c934ce335dabb6fa417ab.png)

[Previous page](https://www.phphelp.com/t/is-it-possible-to-post-two-separate-values-when-an-item-is-selected-with-the-select-option/35025.md?page=1)
