I'm not asking any coding question, I'd just like to know what the 'standard' practice is. If I had PHP spit out a table or list of names/items from a database and then when you click on one of the names/items it then takes you to that page, should these pages be made dynamically or not?
For example, if it was a list of musicians, and then when you click on a musicians name it takes you to a list of their albums and then when you click on the album it has the track list, should these links/pages be done dynamically or is it best to make each musicians page normally. Basically, what I'm asking is should PHP be used to make each page or just to echo out the tables from the database.
Thank you.
Related
I'm almost embarrassed asking this question since I know it should be quite simple yet I can't find an answer to it.
I have a html page with php code in it, that displays let's say a list of companies in a table. I want to make the names of the companies in the table be hyperlinks, such that when a user clicks on a company name, he/she is taken to a page that shows that company's details.
The issue is I cannot have a static page for each company because this list of companies can change every day. So the 'company details' page should be generated dynamically based on what the user clicks.
I am not sure how to approach this. all the questions I see out there seem to talk about static links and pages for static data.
Any guidance is be appreciated!
Every company in the table should have an ID property.
Then when you create the link, do something like this:
Company Name
In your company_details.php you can get the ID of the company from $_GET['id'].
That way you only have one page company_details.php for all companies.
I want to give some information from my database without creating 100 different .php files and redirecting users to each file according to what they want. Is there a possible way i could do that with one page?
I have a table on database named players(basketball players). I want page to be reloaded and print table players(i know how to print) without redirecting to another page which i should make. How i could do that?
For example: Player goes to my leagues.php page(webpage with information about basketball teams) then players clicks on Barcelona team and then it reload page with players of Barcelona(loaded from MySQL database). Is there any possible way? I couldn't find any similar question like that.(If there is i apologise i don't speak proper English and probably i couldn't understand it well!).
The title may be a little vague, but I'll try to explain the concept here.
I have a site in which daily new items ( sports games ), get published, now what I would love is that my users would be able to click on a certain game and get redirected to a new page with more detailed information about that one game.
The thing is, creating every php page seperate for every game each day is a lot of work because also a lot details in the page need to be changed.
Now I was wondering if it is possible in some kind of way that there's a script that reads, OK you have 5 games today, page 1 = id number, title of the page is the matches name, extra info is the info that stands with that id.
I don't know how else to explain this so I hope this was good enough.
Thanks for your time and reading this :)
You can use requests to select the page (the best way is to use $_GET as suggested by gbestard) to select the ID. Then you can have some static content (like url or short article or link to screen shot or something similar) stored in your database under the same ID as the game, and upon clicking on the link to the game, the page is reloaded and you populate it with the new content, that was stored in the database.
You can even store entire pages with static html (as in article or short game description in your case) content and etc in your database and simply call them to populate a div.
If you have something like a custom made admin section of your site, you can add a page to edits it with a js plugin like ckeditor and the creation/editing of articles will be a piece of cake.
It's pretty much a standard case of a CMS(Content management system).
My website allows visitors to search for homes (using PHP and MySql). After the search, they are presented with a list of matches which they can click on to see the detail page for that home. To see the next home, they currently have to click back, then click on the next home in the search results list they want to view.
I would like to make it so that once they have clicked on one home to view the details, they would have a "Next Home" and "Previous Home" link/button to use to navigate the results set without having to go back to the search results page.
I've seen this done, but can't get my head around how to do it. I assume you have to save the recordset from the initial search somewhere, and then recall it on the details page. And you'd have to know that you were looking at the xth home out of Y homes.
Can anyone give me a broad overview of how this would work? Do I save the initial search results in a temp MySQL table and pass that table name to the details page? Or use a session variable to hold the results set? Keep in mind that a visitor could make several different searches during their session.
Any assistance would be most appreciated,
Tom
When I've done this, I've saved the details of the current search in SESSION, and then requeried the database when I've needed to - so you can query it on the detail page to generate a Next and Previous link, and so on. I normally use a SESSION variable called 'parameters', and add the whole of the SQL WHERE statement to it.
If someone's making multiple searches, this will let them make one at a time - subsequent searches will over-write what's already in there. If your users are going to be making multiple searches at the same time using different parameters, you'll need to find a way to differentiate the parameters for each search. You can give each set a unique name by prefixing it with a call to uniqid, and you'll then need to make sure you pass the unique identifier to the detail page, so it can work out which set of parameters it needs to run.
I have a website and I want to make it easier for someone to change certain information being shown without them having to edit the HTML/PHP and using FTP.
At the moment I have this information in a php file which is included in the MYSQL query.
It would be a lot easier if this was done using a form, say a text field where a person can type the table name and it updates on the main page and starts displaying that table instead.
Sorry if I haven't explained this well. :(
I have a good news for you.
Every php/mysql-driven site in the world is made this exact way - to edit site contents using HTML form.
Even first PHP version name was PHP/FI, stands for Form Interpreter.
Even better, a site user doesn't have to deal with mysql - it's all being done in PHP. No need to type table names into form field - all table names already written in PHP code.
Usual PHP application being connected to just one mysql database - so, no need to choose.
As for the tables, it's being done this way: a user selects some human-readable matter, like "Latest news" and being redirected to the PHP script called, say, news.php. this script runs a query for the news table in the database and outputs some HTML formatted news highlights!
Even more, you don't even need to program! There are plenty of ready-made programs, such as Wordpress
store what you want to be editable in a mysql text field.
remove tags you dont want him to see
in the form echo the editable information in a textarea
have him edit
add tags
update the mysql
note depending on the users knowledge depends on how many tags you would like to remove/add. the less per a field the easier.
on more complicated things i like to have the person log in. if he has permission then all the editable fields have an edit button. if he clicks it it goes to a page with a form that he can use to edit that 1 field