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
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 6 years ago.
Improve this question
I'm sorry because i'm pretty sure this was asked like a hundred times before, but my problem is, i dont even know what to search for exactly.
I created a site for our organisation were admins can create events and the users are able to join them.
I already wrote the login, the overview of the events and the form to create users and new events.
I have 2 SQL tables atm
'users' (ID, name, pw, etc.)
and
'events' (id, name, adress, etc.)
Now i want ppl to be able to register to these events, but since im quite new when it comes to PHP / SQL i dont know exactly how to realize that.
I heard something about many to many relationships and foreign keys but im not quite sure if that is what i need.
Thanks in advance for every tip and just call if the infos i gave are not enough.
greetz Moe
Hey I think it's a pretty simple foreign key. The conventional way is to have a table to map them together.
Tables:
users (id, name,...) - all the different unique users
events (id, title,....) - all the different unique types of events
users_events (fk[users.id], fk[events.id]) - map users to events
Let me know if you need any more help!
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.
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 5 years ago.
Improve this question
First of all I must say that I am a complete rookie at web development(2 months working on). So forgive me about any "stupid" comments or questions.
I have a table which holds date stored in MySQL database. I use a form to send these data to the table.
My question is:
"Can I create a hyperlink on each ID of the table so when I click on it, it will display the data of the record BUT on the same page?"
All I could do was to display the table in another page.
First when someone read "responsive table" normally we think on responsive design, maybe the correct title would be data managament from tables.
To answer your question, I would say yes, you can create a hyperlink on each ID display the data, this hyperlink would make another query on the database, the way you want to do i would use AJAX that's really complicated at start, so I recommend you to search some tutorials.
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 8 years ago.
Improve this question
Good day! I am fairly new in PHP and I am trying to develop a website that can retrieve and display stored information from the database. The catch is, the information that will be retrieve will be based on the selected value from the list box (the list box you can create in html).
I have one list box that contains all the names of the users and would like to display all the related information for that user on a specific table in my database.
To be completely honest, I have no idea how to do this. I can retrieve all the values from a specific table in my database and that's all I know.
Hoping someone would be patient enough to teach me how to do this or guide me if this is even possible in PHP.
Thank you in advance.
You will need to read on doing database operations using PHP with PDO.
Once you've done that, the rest will be pretty easy, you will have to learn how to work with forms with PHP,
which you can do here.
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"