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]
Related
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;
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 6 years ago.
Improve this question
I have advertise table and it has ids
Advertise
-----------------------------------
ID Title Code Position
-----------------------------------
1 Ad 1 Somecode Left
2 Ad 2 Somecode Right
3 Ad 3 Somecode Bottom
-----------------------------------
My Display page has different functions so i cannot use while loop to break my other codes and then continue again. I even dont want to add three different queries to fetch each id. I have 3 fixed positions bottom, left and right so i want to add specific id to its specific div.
It is unclear to me what you are asking. But to give you a general idea as to how to pull data from a database, you can some of the following code:
$query = "SELECT * FROM table_name WHERE Position = 'Left'";
$query = "SELECT ID FROM table_name WHERE Code = 'Somecode'";
$query = "SELECT Position FROM table_name WHERE ID = 3";
Please feel free to ask any follow up questions.
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
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.
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.