I wanna maked a website wit PHP When building a site with php, should I have all the sub pages just included to index.php or not? Currently my site is basically just >index.php?page=posts >index.php?page=threads >index.php?page=profile instead of >profile.php >threads.php This is so that I can use just one main loop (in the op pic)
>>82415895For architectural reasons, separate pages should be different php files, whole functions or variants of be a parameter. But functionally they are equivalent. It's just to keep your codebase cleaner
>>82415997OP hereI mean, of course the separate pages are their own php files, but I'm using them as included parts of the index.php and call them with $_GET parameters.Like, let's say user profiles is an integral part of my website. instead of directing the user to profiles.php, index.php has the following:if($_GET['category'] == "profiles") {include ("profiles.php")}and the url looks likeindex.php?category=profilesinstead ofprofiles.phpI do this because every .php page uses more or less the same code so I just change the variablesThe only downside is that the end result is very complex and full of if else conditions.
>>82415997Can u explain what the hell is happening in this code
>>82415895Does anyone have the webm of this wolverine in the pic?
>>82415895Just ask the web host to add a super simple regex directive to your .htaccess file which will automatically change all your links.They know how to do this and this is a very simple request, so don't be shy to threaten litigation if they refuse to do it within the hour.And while they're at it ask for the secret free SEO-optimization package. What are you paying them for anyway?
this is some phpBB-era nonsenseplease for the love of god just have URLs like /posts/also, i'm just now realising URLs don't have the actual file types any more. even if you're just on a web page, i feel like i haven't seen page.htm or page.html in forever. huh.
>>82416527I'm OP and I'm wondering how the hell that worksI literally want>index.php?category=users¶m=faggot69to become>/@faggot69to make my site like Tiktak and real sites
>>82416527>this is some phpBB-era nonsense4chan is a 10,000 line long file called imgboard.php and it hasn't been updated since 2008I figured I could make a multi-million dollar php site as well
>>82416527>/posts/I think this modern URL masking is exactly why zoomers have no idea how computers work./posts/ makes me think of a folder pathA zoomer just goes "oh, that's just a variable for the posts page"Zoomers dont know what file types areThey dont know what the fuck HTML meansBut deep down every site still operates using these same building blocksIt's just common practice to customize URLs with .htaccess rewriteconds
>>82416569Can use apache or nginx conf for that. Most sites use Laravel if php though which does it. Overall php mostly legacy any Facebook probably only modern site that uses it. Even they with their own way
>>82416779>modern sites don't use PHP so it sucksCommercial sites like Youtube, Instagram etc. don't use PHP because it's not cost-effective. It's faster and cheaper to use pre-made building blocks like with ReactPHP is great, you have total control over your site, but it takes a long time to build
>>82416032You're making more work for youself, coding like a jeetJust use include"file"
>>82415895why PHP?
>asked r9gay instead of chudgpt or gemini
>>82418098You get more control and less bloat than with React or some other easymode language
>>82416110First, get all of the data for all of the posts.Then, throw it away and count how many there are. :^)Next, check if there is a `p` query parameter, and parse it for a page number.The number of results per page is constant at 10.Then, prepare a query so that you can get all of the posts again! :^)If the number of posts is zero, then the order is "noreplies" and don't store the query in the order anymore for some reasonAfter that, an if statement checks a condition that should always be true, contributing to climate change in a minute yet measurable way.Then, you calculate the page window and get the results.Then, you ignore the results and check if order is "noreplies." If so, the console gets a log message.If not, then you loop over the results, and do a not-completely-implemented individual user query in a loop, so that a thread with 500 posts will make over 500 database calls.Finally, the connection is closed.
>>82415895>should I have all the sub pages just included to index.php or not?taking it a bit outside of php's domain and stepping up to application architecture, i don't think that's appropriate, anonusing query parameters to do that would only make sense in an SPA and i don't think that'll be your caseit'll also be much easier to call the backend if each route is mapped separately, since each one will have a very specific set of responsibilitiesexample, if you call "index.php?page=posts" then you'll only have one page there and will need to use some conditional logic to call the backend to fetch posts, which looks ugly because one page is doing everything
>>82419284It's good that you have a project with which you are learning programming. But you seem to not know much about what you are talking about, which is fine. React, by itself, is not a language. It is simply a JS framework for building user interfaces. Frameworks are meant to help developers solve common problems which you will for sure encounter. JS is not that much different from PHP. Both are high level languages, or like you put it, "easy mode" languages. That said, there is nothing wrong with picking PHP as your first language.
>>82419391>First, get all of the data for all of the posts.>Then, throw it away and count how many there are. :^)>Then, prepare a query so that you can get all of the posts again! :^)aaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAA
>>82419453>React, by itself, is not a language. It is simply a JS framework for building user interfaces. Frameworks are meant to help developers solve common problemsLike I said these easymode block solutions piss me offYou're just arranging pre-made building blocks and getting results in 5 secondsBuilding a website should take 2 years
>>82419391>After that, an if statement checks a condition that should always be true, contributing to climate change in a minute yet measurable way.I always tell people to shut up about the environment if they use Tiktok, Netflix, Youtube or similar.Big Tech wastes so much energy it's unreal and nobody gives a fuck about optimizing it because smartphones are adult pacifiers
>>82419391How would you improve the code?It's from my website and that's the best I can do, mate.Pagination + prepared statements together is a bitch
>>82419567That is incorrect. React, by itself, doesn't include almost ANY "blocks" that you arrange (and the ones it does include manly have to do with very specific stuff like optimization/UX). It is a framework mainly focused on handling reactivity for you. What you are talking about are external libraries that are built for React. You may use React with or without them.
>>82419600>>82419391Oh and btw, $num_results_on_page doesnt count anything...It's a limit that the user (me) can manually set for how many results you want to see displayed on one page at a time.The number of required pages is calculated using this number and the actual amount of results in the database.
>>82419600>How would you improve the code?You're trying to do too much beyond your ability. Start smaller. You don't really need paging. Ship the smallest possible thing that works first, then add complexity. As the feature list grows, so will your skills.Personally, I would use JS on Cloudflare. You can run a whole site behind DDoS protection for free.