Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

92 users online



stuck on if and else /loading images through it

stuck on if and else /loading images through it

Currently viewing this thread: 1 (0 members and 1 guests)


bcfc4life

bcfc4life

Status: Offline!

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

___________________

http://www.rforsyth54.pwp.blueyonder.co.uk/images/rob.jpg

damell

damell

Status: Offline!
PHP:

<?php

if ($posts 15)  {
echo 
"<img src=\"hot1.gif\">";
} else {
echo 
"<img src=\"hot2.gif\">";
}

?>

___________________

//damell

bcfc4life

bcfc4life

Status: Offline!

now i understand but i get parse error when include it in an echo command so how would i get it to work?

___________________

http://www.rforsyth54.pwp.blueyonder.co.uk/images/rob.jpg

damell

damell

Status: Offline!

show code Shocked

___________________

//damell

bcfc4life

bcfc4life

Status: Offline!
PHP:


<?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.

___________________

http://www.rforsyth54.pwp.blueyonder.co.uk/images/rob.jpg

damell

damell

Status: Offline!

wheres the code that i suggested?

___________________

//damell

bcfc4life

bcfc4life

Status: Offline!

yeh sorry wrong file

PHP:

<?php

while ($rows mysql_fetch_row($result))

$status = if ($rows[7] > 15)  {
echo 
"<img src=\"hot1.gif\">";
} else {
echo 
"<img src=\"hot2.gif\">";
}
// 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>

?>

___________________

http://www.rforsyth54.pwp.blueyonder.co.uk/images/rob.jpg

damell

damell

Status: Offline!

no no no, your best bet is to assign $status as the image, then echo them later, so:

PHP:

<?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 Smile

___________________

//damell

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0097 seconds.