Jump to content

Not working o.O?


3raser

Recommended Posts

Here is my code:

 

<?php

//display data
$get = mysql_query("SELECT * FROM items ORDER BY changeprice DESC");
while ($row = mysql_fetch_assoc($get))

{
// get data
$changeprice = $row[changeprice]; 

if ($changeprice > 0) {

} else {
echo '<tr class="row_b"> 
<td> 
<img name="object" src="'. $row[imagelink] .'" alt="'. $row[name] .'"> 
</td> 
<td> 
<a href="http://domination.comyr.com/viewitem.php?id='. $row[itemid] .'">'. $row[name] .'</a> 
</td> 
<td>'. $row[price] .'</td> 
<td class="t5"> 
<span class="rise"> 
'. $row[changeprice] .'
</span> 
</td> 
</tr>';
}
} ?>

 

I'm trying to make it so it only echoes out the price RISES. But when I test it, it still echoes out the ones that are below 0 (-2 is one of them.) Any reasons why?

Link to comment
https://forums.phpfreaks.com/topic/191265-not-working-oo/
Share on other sites

If I were you I would only grab the price rises from the database.. I will clean up the code a bit..

$get = mysql_query("SELECT * FROM items WHERE changeprice > 0 ORDER BY changeprice DESC");
while ($row = mysql_fetch_assoc($get)) {
echo '<tr class="row_b"> 
<td> 
<img name="object" src="'. $row[imagelink] .'" alt="'. $row[name] .'"> 
</td> 
<td> 
<a href="http://domination.comyr.com/viewitem.php?id='. $row[itemid] .'">'. $row[name] .'</a> 
</td> 
<td>'. $row[price] .'</td> 
<td class="t5"> 
<span class="rise"> 
'. $row[changeprice] .'
</span> 
</td> 
</tr>';
}

It may also fix your problem.. I fear it is because the values being pulled from the database are strings NOT integers or a number..

Link to comment
https://forums.phpfreaks.com/topic/191265-not-working-oo/#findComment-1008465
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.