I have this code:
<?
// includes
include("db-connex-f.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// generate and execute query
$query = "SELECT * FROM name_game ORDER BY ID DESC";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>
<span class=textbody><li><a href="name_detail.php?id=<? echo$row->id; ?>"><? echo $row->name; ?></a></li></span>
<?
}
}
// if no records present
// display message
else
{
?>
<font class="textbody">No Names Items Available</font>
<?
}
?/ close database connection
mysql_close($connection);
?>
If a field in the table name is = 1 I want it to display a headline and an external link, if it is = 0 I want it to display the headline and a link to index.php?ID=
Is this correct?
<?
if ($external = 0)
{
// iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>
<span class=textbody><li><a href="name_detail.php?ID=<? echo$row->ID; ?>"><? echo $row->name; ?></a></li></span>
<?
}
}
// if no records present
// display message
else
{
?>
<span class=textbody><li><a href="<? echo$row->url; ?>"><? echo $row->name; ?></a></li></span><?
}
?/ close database connection
mysql_close($connection);
?>