3raser Posted February 7, 2010 Share Posted February 7, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/191265-not-working-oo/ Share on other sites More sharing options...
Buddski Posted February 7, 2010 Share Posted February 7, 2010 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.. Quote Link to comment https://forums.phpfreaks.com/topic/191265-not-working-oo/#findComment-1008465 Share on other sites More sharing options...
3raser Posted February 7, 2010 Author Share Posted February 7, 2010 Ok, it's partly working now. When I change it to greater than 0, it sends out the ones below zero....and when I change it to smaller....nothing comes out. Quote Link to comment https://forums.phpfreaks.com/topic/191265-not-working-oo/#findComment-1008466 Share on other sites More sharing options...
3raser Posted February 7, 2010 Author Share Posted February 7, 2010 Wait, nvm. I think it's solved now.. Quote Link to comment https://forums.phpfreaks.com/topic/191265-not-working-oo/#findComment-1008469 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.