Need search a value from database from comma separated string [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a table in database that is TEXT field. In this table i have stored my product ids . Now when i go to cart and get all product id of cart i want to match from database field and get only those ids that there stored in product id.
Please see image first.
In this field you will see "check_values" field. here all product ids are stored in comma separated.
Let me take a example
Like i have purchase a product that product id is 161. So i want to match 161 id from "check_value" filed and get only those ids (from images) that having 161.(11,14,15).
Hope you understand my question.

You can use FIND_IN_SET e.g.
SELECT * FROM images WHERE FIND_IN_SET(161, check_values) > 0

Related

What SQL query should I use to output the value of my 2 tables? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am a student and is new to MySQL
I have 2 tables, ors_uniform contains 7 products that has 9 sizes (XS-5XL).
ors_prices contains the fk of table1 and the prices per size (9 sizes)
I wanted it so that when I output the inventory of the products, the price will be shown next to it. I know how to do that using php already but I don't know what MySQL query to use.
I currently just use SELECT * FROM ors_uniform
2 tables
let's assume the fk is a foreign key and it is available in both tables.
select * from ors_uniform join ors_prices on ors_uniform.fk = ors_prices.fk;

Delete articles from db decrease/increase order php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
First of all I wish you a new happy year! So I have 3 articles for example and each of them has an order, like 1,2,3. If I want to delete the last article for example, the order of the other articles still remain the same 1,2. But if I delete the first article the orders of the others should decrease with 1 and if I delete the middle one only the order of the last article should decrease.
Now how to do this in php? I refer to delete in database
Any idea is appreciated.
I don't have any code yet because I wanted to find first a solution, I only give the id of the article, the order and the category from which it belongs:
if($_POST['actiune'] == 'updateArticle'){
$id_article = $_GET['id'];
$ord = $_GET['order'];
$categ = $_GET['categ'];
}
You could do an update after each delete. Something like:
UPDATE [ArticleTable] SET [OrderColumn]=[OrderColumn]-1 WHERE [OrderColumn]>=[ORDERVALUE_FROM_DELETED_ITEM]

How to make for each user, documents start by id 1? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to make database for users and every user have documents which will line up in this order for
user1(document1 have id 1, documnet2 have id 2, documnet3 have id 3, etc...)
user2(document1 have id 1, documnet2 have id 2, documnet3 have id 3, etc...)
?
Create two tables to accomplish this.
The first table should contain your users. Example:
|id|username|password|
|1|user1|1234|
|2|user2|1234|
Then create a second table containing your documents
|id|document|owner_id|document_id|
|1|adocument.doc|1|1|
|2|anotherdoc.doc|1|2|
|3|adocument.doc|2|1|
|4|anotherdoc.dco|2|2|
In this example you see that the documents in the document-table point to a owner_id. This should be the id of the user in the users table.
This is just to head you in a direction for a solution to your question. We cant write the entire code for you, so start googling a bit on mysql.

Create Hidden Association in PHP/MySQLi [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a MYSQL Db that has a PROFILE-TABLE as well as a KEYWORD-TABLE which holds profiles and the other holds keywords associated with those categories.
Profile-Table
UserID
UserName
UserDept
UserPhoto
UserKeyword > indexes KeywordName (from Keyword-Table)
UserAssociations
Keyword-Table
KeyID
KeywordName
I need to make an association with the categories/keywords.
I want to add a hidden field (UserAssociations) onto my profile form which will display a hidden association where as when you click on a category via a link on the page, it will index first those that are associated. I have written this in PHP and use MYSQLI database.
I have never created associations before needing this. What would be the easiest way to achieve this functionality?
From what I gather, you wish to associate a user profile with keyword. What you need is another table to represent the relationship, something like this:
profile_keywords ( <UserID>, <KeyID> )
Hence, if UserID 4 has associated himself with keyword ID 3, you would have an entry in profile_keywords like this:
UserID, KeyID
---------------
3 4

Creating a table per user in PHP? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm very new to all this...and for a project work in my college I have decided to make an online shopping website.
I am stuck at the sign up part.
I wanted the users to have a separated table for themselves that allow them to store the products that they have added in their cart so that they can keep adding more products later as well.
But as I read in other questions in all your links, creating a table per user seems to be a very bad idea.
but otherwise how can I do it? Please help.
Let me explain in detail.
I guess you have already created table for user and product. if not then you need to create table for user and product with unique value of user_id and product_id respectively.
Now create user_shopping cart table with following fields
user_id
product_id
product_qty
You can update user_shopping as per you need.
Make one table that contains the columns user_id and product_id.
That way you can associate products with users without needing a table for each user.

Categories