The result script below has a mySQL field "register" and I want to use that field, So I can choose to show a link or not.... I tried using an If statement:
But I`m doing somthing wrong.. Can anyone help?
Basicly if $register = 1 echo "href//mylink ere etc...
if $register = 0 nothing...
Thanks in advance
<?php
// create connection
$connection = mysql_connect("localhost","user","pass")
or die("Couldn't make connection.");
// select database
$db = mysql_select_db("a0000490", $connection)
or die("Couldn't select database.");
// create SQL statement
$sql = "SELECT title, class, description, date, register
FROM events
ORDER BY date ASC";
// execute SQL query and get result
$sql_result = mysql_query($sql,$connection)
or die("Couldn't execute query.");
// start results formatting
echo "<TABLE BORDER=0>";
//color format
$setcolor = 0;
while ($row = mysql_fetch_array($sql_result))
{
if($setcolor == 0)
{
$bgcolor = "#FFFFFF";
$setcolor = 1;
} else {
$bgcolor = "#CCCCCC";
$setcolor = 0;
}
$title = $row["title"];
$class = $row["class"];
$description = $row["description"];
$date = $row["date"];
echo "<TR>
<TD bgcolor=\"$bgcolor\"><div align=\"center\"><font size=\"2\"><b><font face=\"Times New Roman, Times, serif\">$title</font></b><br>$class<br>$description<br>$date<br></div></TD>
</TR>
";
}
echo "</TABLE>";
// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>