Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.