I can create dynamic pages already, and it is working, but the landing page loads very slowly.
I would really like some help. Below is how my site functions.
Let's start with a link in http://example.com/search.php
:
<?php
session_start();
//(pretend there is code here that gets, decodes, and displays data from an api)
$title = $titleFromApi;
$a = $dataFromApi;
$_SESSION['storeTitle'] = $title; // stores 'title' in a session variable
$_SESSION['store_a'] = $a; // stores 'a' in a session variable
echo '<a href="http://example.com/'. $a .'/' . $title .'> ' . $title . '</a>';
// the line above is a clickable link that will take them to the landing page
?>
Now here is the landing page (http://example.com/$a/$title
):
<?php
session_start();
$al = $_SESSION['store_a']; // stores session variable in new variable 'al'
$getter = 'http://api.somewebsite.com/dev/' . $al . '/get_these_variables';
// the line above gets data from an api using variable 'al'
// (pretend that there is code here that decodes the data)
// the code below displays the data retrieved from the api
foreach($data as $entry){
echo '
<div>
' . $entry['decoded_data_1']
. '
</div>
<div>
' . $entry['decoded_data_2'] // and so on
. '
</div>
'; // ends echo
}
?>
I just learned about sessions today (I thought it would make things faster); before, I sent the data into the address bar from search.php, then read it on the landing page to carry the variables over (cringe, I know, I am very new to php and development in general). The page load speed of the landing page has not changed.