I have a list of product names and their image, as I want to avoid repeating the same page for several products. I'm doing the following:
I am passing the a variable id
the name I want to appear in the products.php page so for example I am using products.php?id=anyname
and use $_GET
to know the id name variable. Then I am populating a menu with an array wich contains all the names I need
For example the in the menu I will have displayed :
key: gfon
and the value: Fondant pt
and then an image with gfon.png will be loaded
This is the code
<li>
<a href="menu.html" style="padding:8px 30px;">THE MAIN MENU</a>
<ul>
<?php
if (isset($_GET['id'])) {
$product = $_GET['id'];
}
$array = array(
"gfon" => "Fondant pt",
"galf" => "Alfajores gy",
"gdom" => "Domino tre",
"gesp" => "Espiral ere",
"gsan" => "Sandwich we ",
);
foreach($array as $key => $val) {
echo "<li><a href=\"http://www.mysite.com/products.php?id=".$key."\">".$val."</a> </li>";
}
?>
</ul>
</li>
Then comes the section which will change a picture depending on the product chosen
<?php
echo "<h1>";
switch ($product) {
case "gfon":
echo "Fondant</h1>";
break;
case "galf":
echo "Alfajores</h1>";
break;
case "gdom":
echo "Domino</h1>";
break;
case "gesp":
echo "Espiral</h1>";
break;
case "gsan":
echo "Sandwich</h1>";
break;
}
echo "<p> <a href=\"http://www.mysite.com\"><img src=\"images/".$product.".png\" alt=\"" .$product." width=\"300\" height=\"300\" align=\"right\"/> </a>"
?>
Sometimes it is working and sometimes not, I am getting this error occassionally
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Also I do not have access to the log file :( is there any better way to go to solve the this?