0

I have a php foreach loop which displays a list of events (organizer, eventname, , hour-minutes, etc...). One event per line like that :

Me | My eventname | 17h45 |

On a very similar website (but with a lot of complexity) I found this in the source page of display events :

<td align=left><a href='seance-de-coaching-decouverte-1364321.html'>Séance de coaching découverte</a></td>

So, at the creation of this event, do you think a new HTML file has been generated ? How can I make that ? What is the good practice ? Maybe I need JS ?

Sorry if my question(s) are not very clear...

1
  • Where is your event information being kept? In a database? Do you just want a page that displays an individual events information? or do you specifically want to generate a new html page for every event that is created? My advice is to store info in a database and use a query string url or url re-write to search the db for the events information and have a php script that displays individual events based on the id in the url. Commented Mar 16, 2015 at 19:33

3 Answers 3

1

You should seach about urlrewriting here's a link where you can learn about it https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

The website that you are talking about have probably a php file who dynamically output the appropriate html page depending on it's id wich is 1364321 in the link given

Sign up to request clarification or add additional context in comments.

Comments

0

I don't think they generate a new HTML file for each event. Most probably they just use .htaccess to rederict all requests like "sometext-digits.html" to, let's say, event.php. This event.php parses request URL or GET request(depends on their .htaccess directives) and gets those digits, which are the ID of the event, and gets everything from DB.

Yes, it's generaly good and helps to make URL look user-friendly. You can easily make this and no need for JS.

Comments

0

Yes, the HTML on that page was probably generated with PHP or some other scripting language.

Here is a snippet of PHP code that might help you (replace variable names and array keys with yours):

foreach($events as $event) {
    echo '<tr><td>' . $event['organizer'] . '</td><td>' . $event['name'] . '</td><td>' . $event['start_time'] . '</td></tr>';
}

For each event it creates a table row with three cells: event organizer, event name and event start time.

Obviously you need to add HTML markup for table header before, and close the table after foreach loop, to be valid.

You don't need JS, unless you want to have table content dynamically loaded without refreshing a page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.