Hi!
I am trying to make list of my DVDs with PHP and MySQL.
Everything has gone fine until now :-(
I'm a real newbie so be good to me :-)
My problem is that I want a variabel, col[17], change to different amount of pictures.
col[17] can have numbers 1-5 or ----
If number 1 then <IMG SRC="star">, 2 then <IMG SRC="star"> <IMG SRC="star"> and so on.
This is my page code:
<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
.rad1 {background-color: #888888}
.rad2 {background-color: #cccccc}
-->
</STYLE>
</HEAD>
<BODY>
<?
$db = mysql_connect();
$databas = mysql_select_db("filmer");
$info = "SELECT * FROM dvd ORDER BY titel";
$resultat = mysql_query($info);
function colorSwitch()
{
static $style;
if ($style == "rad2") {
$style = "rad1";
} else {
$style = "rad2";
}
return $style;
}
?>
<TABLE BORDER="1">
<TR>
<TD WIDTH="100"><B>Titel:</B></TD>
<TD WIDTH="100"><B>Original Titel:</B></TD>
<TD><B>Betyg:</B></TD>
</TR>
<?
while ($col = mysql_fetch_row($resultat))
{$rc = colorSwitch();
echo "<TR CLASS=\"$rc\">
<TD>$col[1]</TD>
<TD>$col[2]</TD>
<TD>$betyg</TD>
</TR>
";
}
?>
</TABLE>
<?
mysql_close($db);
?>
</BODY>
</HTML>
And this is my if-code I tried to use:
if ($col[17] == 1)
$betyg = "<IMG SRC=\"star.gif\">";
elseif ($col[17] == 2)
$betyg = "<IMG SRC=\"star.gif\">...";
elseif ($col[17] == 3)
$betyg = "<IMG SRC=\"star.gif\">...";
elseif ($col[17] == 4)
$betyg = "<IMG SRC=\"star.gif\">...";
elseif "$col[17] == 5)
$betyg = "<IMG SRC=\"star.gif\">...";
else = "----";
Obviously it's not that simple because all rows get the same result regardless of col[17]'s content.
I hope you all understand what I mean and i'm sorry if it's crappy english :-)
Thanks for any help!!