i am currently putting together a php site, but i have got a little stuck and wondered whether someone could help. I have 3 HTML links when clicked on i would like to change the php content within my HTML it is held. My code is underneath, the three links i refer to would be "now showing", "coming soon" and "arts council" they are without the link tagging below. The 4 small tables below complete the "now showing" section. When clicked on the coming soon link i would like to change the content of these tables.
Though the other sections might have to hold more than just the 4 tables. I was thinking is it possible to use the php include tag somehow? Have each section in a different page and included on page when link is clicked.
Thanks
<?php
//open data file
$fp = fopen ("films.csv", "r");
//this uses the fgetcsv function to store the info in the array $data
$dataA = fgetcsv ($fp, 1000, ",");
$dataB = fgetcsv ($fp, 2000, ",");
$dataC = fgetcsv ($fp, 3000, ",");
$dataD = fgetcsv ($fp, 4000, ",");
?>
<!-- use $data[n] for fields -->
yea you could use a switch to call the correct section of data to include. You can pass the values of which data sets to include in a lot of different ways but here one using the URL.
First you would want to see if there are multiple sections to display and you have the $_GET array with all the values.
When you have your values you can use a switch but you need to loop through the array containing your showdata values, so put the switch inside a foreach. You can order the array to order the output either now or when you build it.
PHP Code:
foreach($_GET as $v){ switch ($v) { case 1: echo "data set one"; break; case 2: echo "data set two"; break; case 3: echo "data set three"; break; } }
edit: remember that page.php?showdata=1&showdata=2 will only write one value to the GET array and overwrite the first one with the second.
You could generate a neater URL like this www.url.com/page.php?showdata=1_2_3
and explode the GET['showdata'] value on the underscore to generate the array to loop through.
GET strings are easy to tamper with so, if that matters, secure it wth an MD5 hash and a secret key.
Bookmarks