
March 24th, 2003
10:14 AM
stuck on if and else /loading images through it
what i want is to say if $posts is greater than or equal to a number eg 15, then show the image hot1.gif else if $posts is less than 15, show the image posts.gif...
how would i go about doing that?
thx in advance
___________________


March 25th, 2003
11:46 AM
now i understand but i get parse error when include it in an echo command so how would i get it to work?
___________________


March 25th, 2003
11:53 AM

<?php
// Connect to the database
$db = mysql_connect("localhost","rforsyth","rforsyth54");
mysql_select_db ('fullsite');
// Ask the database for the information from the links table
$query = "SELECT * FROM threads where board_name='$boardid' AND thread_top='0'";
$result = mysql_query($query);
// Now we print out the results, starting by making a table
echo ("
<table cellpadding=0 cellspacing=0 border=0 bgcolor=003493 width=100% align=center><tr><td>
<table cellpadding=4 cellspacing=1 border=0 width=100%>
<tr bgcolor=#003493 id=cat align=center>
<td bgcolor=#3E61A0 align=center nowrap colspan=3><font face=verdana,arial,helvetica size=1 ><b>Thread</b></font> </font></td>
<td bgcolor=#3E61A0 nowrap><font face=verdana,arial,helvetica size=1 ><b>Thread Starter</b></font></td>
<td bgcolor=#3E61A0 nowrap><font face=verdana,arial,helvetica size=1 ><b>Replies</b></font></td>
<td bgcolor=#3E61A0 nowrap><font face=verdana,arial,helvetica size=1 ><b>Views</b></font></td>
<td bgcolor=#3E61A0 nowrap><font face=verdana,arial,helvetica size=1 ><b>Last Post</b></font></td>
</tr>
");
while ($rows = mysql_fetch_row($result))
// Here we make the script keep making new rows until all the links in our database are shown, this is called a loop
{
echo ("
<tr align=center>
<td bgcolor=#436BB5>status</td>
<td bgcolor=#3E61A0></td>
<td bgcolor=#436BB5 align=left width=70%><font face=verdana, arial, helvetica size=2 ><a href=index.php?action=thread&thread=$rows[0]&boardid=$boardid>$rows[2]</a></font> <font face=verdana,arial,helvetica size=1 ></font></td>
<td bgcolor=#3E61A0 width=30% nowrap><font face=verdana, arial, helvetica size=2 >$rows[6]</font></td>
<td bgcolor=#436BB5><font face=verdana, arial, helvetica size=2 >Replies</font></td>
<td bgcolor=#3E61A0><font face=verdana, arial, helvetica size=2 >Views</font></td>
<td bgcolor=#436BB5>
<table cellpadding=0 cellspacing=0 border=0 width=100% id=ltlink><tr align=right>
<td nowrap><font face=verdana,arial,helvetica size=1 ><b>last post</b></a></font></td>
<td nowrap></a></td>
</td>
</tr></table>
");
}
// Finally we close off the table
echo "</table>";
?>
there you go i want it to be displayed where status is but it just wont work.
___________________


March 25th, 2003
11:57 AM
wheres the code that i suggested?
___________________
//damell

March 25th, 2003
12:03 PM
no no no, your best bet is to assign $status as the image, then echo them later, so:
<?php
if ($row[7] > 15) {
$status = "<img src=\"hot1.gif\">";
} else {
$status = "<img src=\"hot2.gif\">";
}
?>
then echo $status where ever you want it, should do the trick 
___________________
//damell