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've read tons of questions who are in many ways the same as this one. But I just can't seem to understand how I am supposed to do this the proper way.
I've got one table with my pages.
And one table with portfolio items.
I want to be able to say to a portfolio item: You are linked to the welcome page now.
My approach:
In my pages table i've created a "items_linked" column. Inside this column the id's of the linked portfolio items get stored.
In the html of the 'edit page' I have a select with all my portfolio items, whichever I select gets stored inside the "items_linked".
I use the mysql UPDATE to get the information inside the database.
However this way I can't link a portfolio item to more than 1 page.
Because UPDATE removes the old information.
So I was guessing I needed a way to keep the old info, and add new info if the item is linked to a second page.
Can someone push me into the right direction?
Since we have no way of knowing what we are replacing I can only give you an idea of what to do:
UPDATE `table`
SET `myColumn` = CONCAT(`myColumn`, other_data)
WHERE some_condition_exists
This causes the information in myColumn to have additional data appended to it.
Here's the thing (caveat ahead): If you need one item to be linked to many items what I have described is not the way to go. You should have a table between the two you have already which will allow a one-to-many relationship between pages and portfolios. Please consider refactoring your database design.
Related
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 5 years ago.
Improve this question
I'm building a website that contains articles, these articles won't be shown until the user is logged in, I'm planning to add two buttons, the first one is called "follow this article", the second is meant to make the article as a favourite. My question is how can I structure that in my database?
Should I just add a table that contains id_article, id_user, followed(1 or 0) and favourite (1 or 0), or is there another solution that would let me economize more memory space?
NOTE: My website will have lots of articles that will be visited by a lot of users.
Make two separate relations: articles_followed (id, id_article, id_user) and articles_favourite (id, id_article, id_user). This will give you enough flexibility in:
adding new attributes, specific for each relation,
sharding your database (at some point): it'd be easier to move one relation from another since they are not depending on each other,
concurrent update: you can use separate locks on these two, in addition, you'll have fewer issues with transaction visibility,
you don't need to keep is_followed or is_favourite flag: if there's an entry, then it means that article is followed (once unfollowed, simply remove the line)
Think about your domain classes structure -- which option would be more convenient to code? I bet, in case of two separate relations, it would be clearer.
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 5 years ago.
Improve this question
I am in need of creating a table that will get its data from a database (this is done:) ).
The users must be able to filter the table if they want to find specific rows based on the their input.
The table will have around 33 columns which not all of them will be visible, but the user can drag and drop new columns whenever he likes. and be able to filter the table using values from these columns as well.
The table will look like this and every time the user inputs something on the top of a column then the table will get filtered based on that column. also multiple filters can be placed.
Any suggestions on how to do this? is it even possible?
I would like suggest you to use http://yadcf-showcase.appspot.com/DOM_source_chosen.html jquery plugin for datatable also it works with ajax source
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
Okay, so currently I'm creating a website from scratch for my small online shop and am stuck on where to even begin when it comes to my Products page. Currently, I have 1 page that displays all 50 of my products. I plan on expanding my products and do not want someone to be scrolling down the whole page. I would like to add multiple pages that you can click through and I believe I can accomplish this through Pagination. Now, this is the part where I get confused : say I only want 25 products to be displayed per page and I add a new item to the first page - how do items get 'bumped' to the page 2, 3 etc.? I would imagine there is some function to accomplish this, but the only way I can think of is doing this the brute force way of manually moving a product out of one page and onto another. Any suggestions??
Currently, my website is coded in all HTML / CSS and I currently just learned how to use PHP to mass edit certain areas of the website -- I am in the learning stages! Any suggestions would help. Thanks!
You need the help of a database to paginate your products in sets.
Basically, the database will have a "Products" table, each row in the table will represent a single product. You will use PHP to ask the database to retrieve the first/next N rows and then write out the appropriate HTML around each returned row to create a list of products.
There are lots of tutorials on the web to help you learn while you practice. Good luck!
There is no way to do that on static HTML web-site.
You need server-side script (e.g. PHP script) for splitting your product list by pages. By the way, you should store your data in DB and it should be done on the DB-side to not overhead your PHP side.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm making a forum where every topic can have a set of tags(like the tags on stack overflow). I'm storing each topic as a row in a table that has columns for storing timestamp, title, description, etc.
What would be the best way for storing each question's tags in the mysql database preferably using php only? Should I create a new table for each topic and store the tags on seperate rows in that table? I'm sure there are more efficient ways. Please help.
Performance is an issue. And I must also be able to retrieve all the topics that belong to a particular tag.
It might be a good idea to create a separate table just for the tags and then link it to the other one by creating a column in the new one that references the Topics' ids in the first. This way if wouldn't make the original table a mess and you can still set topics for each of the tags. Hope this helps.
In fact your shoud use two tables.
Tag - table to store tags
Topic2Tag - to store relation betwen tags and topic
so your system will get max flexibility
Or you can store tags in one column of topic table separated by comma, but if later you wil try to do something whith tags .... "this is heavy"
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am new to PHP and have learnt it through online tutorials. I am am developing my own business website. I am looking for some guidance related to making dynamic web pages. It's something like, if Db contents are like Continent>North America>USA>States>Area>City and other geography. My question is, do I have to create different tables for each content or can it be in single Table? Moreover auto generate customer id/property id is that the same what we chose in table rows. I am sorry for my stupid question.
My confusion is that if someone searches for example USA, it gonna appear as many timesas in columns where I had to use it for subordinate area or cities.
Each table is a set of several peices of information. For each peice of information, you create a new row inside that table. You do not need a seperate table for each peice of information, however if you need a different layout for this information, you then create a new table.
I hope this helps :)
EDIT As requested by your comment, one thing you could do would be have a column named 'region' or something in the table, and in there you could insert information such as GB>SCO
I would create one table for customers with autoincrementing id, and another table for purchases where each new purchase gets the customers id. like purchases.customerId
Then you can create a view where you link customers.id and purchases.customerId For example.
If you want a very nice youtube tutorial series about mysql, u really should look at this http://thenewboston.org/list.php?cat=49