I´m sitting and working on some new PHP code, still going strong to learn good PHP🙂 but now I´m stuck.
I want a code that changes the value of a link to get another question from my database. If you take a look at this address http://www.spelkontroll.net/Bilder/ljusaredesign.png you will see a big light box that has big titles that says Recensioner, Beta-tester, Retro, SK-TV (Swedish Words) and I would like so that if you click on the Recensioner link then it gets the five latest reviews from my database and prints out a link to it and text and if you click on the Beta-tester then it would do the same but it would print out the 5 latest Beta-reviews with the links and text to them.
I have tried to make a code for it but I haven´t succeded. Here is the code that I have made, it works a little I can change $test value to diffrent tables from the database but I cant make it change links and stuff like that.
Here is the code:
<div id="latestlinks">
<?php
$test = "";
if (!isSet($_GET["type"])) { //Du valde "Alla" i menyn
$test =" SELECT * FROM game ORDER BY id DESC LIMIT 5";
//fånga detta fall för att veta att type är satt nedan,
//annars kan du få problem.
}
else if ($_GET["type"] == 1)
// I can change this value but if I add a varibel then the code dosen´t work anymore.
$test =" SELECT * FROM game ORDER BY id DESC LIMIT 5";
else if ($_GET["type"] == 2)
$test =" SELECT * FROM betagame ORDER BY beta_id DESC LIMIT 5";
else if ($_GET["type"] == 3)
$test =" SELECT * FROM game ORDER BY id DESC LIMIT 5";
else if ($_GET["type"] == 4)
$test =" SELECT * FROM game ORDER BY id DESC LIMIT 5";
else {
//Vad du vill ska hända då -
//tex att resultatet blir som för "alla" eller ett felmeddelande eller...?
}
//OM det är frågan ovan som gäller har du inga andra WHERE villkor, så...
?>
<br />
<span class="latestreview"><a href="<?php echo $me."?type=1"; ?>">Recensioner</a></span>
<span class="latestbeta"><a href="<?php echo $me."?type=2"; ?>">Beta-tester</a></span>
<span class="latestretro"><a href="">Retro</a></span>
<span class="latestsktv"><a href="">SK-TV</a></span>
</div>
<div id="latestbox">
<?php
$query = "SELECT * FROM game ORDER BY id DESC LIMIT 5";
$result = mysql_query($query);
echo "<table width='570' height='450' cellpadding='0' cellspacing='0'>";
while($row = mysql_fetch_assoc($result))
{
echo"<tr bgcolor='#DBD8CA'>";
echo "<td height='90' width='130'><div class=picture><a href=\"nyheter.php?news_id=".$row['news_id']."\">".$row['video']."</a>"."</div>"."</td>";
echo "<td height='90'><div class=game><a href=\"nyheter.php?news_id=".$row['news_id']."\">".$row['game']." - ". $row['format']."</a>"."</div>"."<br />";
echo "<div class=shorttext>".$row['introduktion']."</div>"."</td>";
echo"</tr>";
}
echo "</table>";
?>
</div>