lundi 4 mai 2020

Checkbox Question using form and two tables to store multi selected values then to retrieve selected values for display

I'm using a PDO crud to make a product printout, but I'm running into issues. I have two tables. Table1 (about 50 products)- ProductID, ProductName, ProductDescription, ProductImage; Table2 - LikeKindID, LikeKindChecked.

I am creating an add, update form for products to have the user check off or select other Products which are similar. I would like to have the selection options based on the ProductName fields in the table EXCEPT the actual ProductName working on. These available selections will change with the amount of Products. The value of the input I would like stored in the database is the ProductID 1,2,3,4. How do I create the input so the ProductName Id(s) are stored in the database? I am using SELECT ProductName FROM Table1 and using a Foreach to echo out the ProductName. Do I also SELECT the ProductID to use as the value? Do I have to do some type of implode to store?

I'm also creating a read button for each Product. The user will be able to print out the HTML page. Here is the other issue I'm having problems with. Under the Product Information section I would like the similar Product Images and Names to show. Some Products will have one similar product and other Products will have multiple similar products. --- How do I read the value? I was told I need to do an explode to separate the LikeKIndChecked values and then Select ProductID, ProductImage FROM table1 and use fetch to display. Am I on right path?




Aucun commentaire:

Enregistrer un commentaire