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 just begun to learn PHP and there is something that is bugging me. I often see php pages, which load content the following way:
index.php?id=16
What does this mean? Is there a single index.php file and the content of a different file (in this case 16) is loaded into this page? Is this advantageous?
And: how do I create such id-pages?
I've already googled it and made a search here, but couldn't find any answers...
If you could simply tell me how this function is called it would already help me a lot!
Thanks in advance!
This means you are calling your index.php file, and you pass it a parameter called id with the value 16. You can access this value like this
$_GET['id']
It allows you to have dynamic content in your page for example.
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 2 years ago.
Improve this question
a challenge like this $_GET['2020'] snippet boring me a long time, i want to know how this work, but do not know which keywords to search, maybe how the parameter works?
$_GET reads querystring parameters from the URL. So if someone goes to your PHP script with a URL like http://servername/scriptname.php?2020=ABC then when the PHP script runs, the variable $_GET['2020'] will contain the value ABC.
More info is available in the documentation: https://www.php.net/manual/en/reserved.variables.get.php
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 4 years ago.
Improve this question
I am trying to make this page:
https://mediastreet.ie/media-jobs/role-65678
same as this page using htaccess:
https://mediastreet.ie/media-jobs/role
So basically /role-65678 is a parameter like role-{parameter}. So when on /role-65678 i have a script that fetches this (65678) and displays the job according to it.
Rather than editing your htaccess file, I would just reccomend sticking with a good old get method.
Use https://mediastreet.ie/media-jobs/role?id=65678
Then in the index.php file in the directory "role", use the get functionality as shown below.
<?PHP
$id = $_GET["id"];
//Code to follow
?>
Past experiance tells me this will save alot of htaccess headaches!
All the Best.
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
Can anyone tell me how to Dynamically generate a new php file? Like generate it and then set it's code. Say that there was a user who created an account. When he created that account I would like it to generate his profile page.
Thanks!
You can do this using file_put_contents, but it's bad practice. It's much easier/better to just have one PHP file, profile.php for example, which takes a GET parameter for the user ID, then dynamically displays the correct information based on the user ID.
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
How can I see the Edit Mode page is the link is written like:
<small><i>Edit Mode</i></small>
In the above case, if I click the Edit Mode button in the homepage, does it mean editz will be assigned a value as 1?
Another question is if I have three php files a.php, b.php and c.php, which all check isset($editz), how can I redirect the page to a.php, rather than file b or c if I click the Edit Mode button?
Sorry maybe my question is too simple a naive, but I am a newbie to php, it is my first time tough php code. Please be kind to share some light:)
Just to give some sort of answer to this, spanning from the comments:
Anything following a ? in a URL is a query string, and the parameters (each separated by &) can be accessed with the $_GET['parameter_name'] function. In this case, $_GET['editz'] was needed.
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
I am making a website using HTML. I am not familiar with PHP. I need the navigation and header part to be in a single place. i.e., Once I change the menus in one place it should reflect in all other pages. Kindly help me on this.
Thanks in Advance.
You could use include or require to add your Menu-Html file in every page you wish.
you could add something like this:
<?php
include('menu.html');
?>
wherever your menu should appear in your HTML, having a menu.html file of course.
and you'll need an apache server or any other that can 'read' your php files.
include php documentations
require php documentations