Log in

View Full Version : Resolved How to hide entry when value is 0



Bar2aYunie
06-23-2010, 09:37 PM
Hello,

I have some numbers in two of my columns of my database. Sometimes, this number is set, sometimes, this number is 0. When it's 0, I'd like to hide it, make sure that it's not displayed.

Here's my current code: (part of it)



<?php

while($item=mysql_fetch_array($finalQuery)){
$base_m=5;
$item['col1'] = round ((($item['col1']+5) *1.85),0); $item['col01'] = $base_m*(ceil(($item['col1'])/$base_m));
$item['col2'] = round ((($item['col2']+5) *1.85),0); $item['col02'] = $base_m*(ceil(($item['col2'])/$base_m));
>?

<td width="50%" align="center"><h4><?php echo "{$item['col01']}?></h4></td>
<td width="50%" align="center"><h4><?php echo "{$item['col02']}?></h4></td>


If both columns are filled with numbers, the math function is added and the numbers are filled perfectly in the table.

However, if one of those numbers is 0, the math function is added and the number turns to 10. I'd like to hide this. Or even all entries that gives a 0, so the math function wouldn't even be calculated at all... In either way, it cannot be shown in the table.

I tried adding it in the select query (where value > 0), but that doesn't work and returns no results at all (nothing, not even other results I'm trying to get after this part of cod). I also tried to use something like "if ($item['col1'] > 0)", but it gives me an error... or executes fine when there's no 0, when there is a 0, I see nothing.....can't get it right.

Does anybody have any idea's?

bluewalrus
06-23-2010, 10:11 PM
Was the select you tried was something like

Select value1 from number_table where value1 > 0

and is the value1 saved as an int or numeral and not a string?

Bar2aYunie
06-24-2010, 05:36 AM
Yeah, and it is saved as float. Since I have to calculate with these numbers.... But I also got two more variables (which have nothing to do with this question though) in my select WHERE query. So maybe that's messing each other up?

bluewalrus
06-24-2010, 03:43 PM
It should still be able to distinguish.

Can you post your select and/or is it the same result when you trigger the select from the DB and from the php?

Bar2aYunie
06-25-2010, 05:44 PM
Sure, though I don't have the values in the select function, since that doesn't work.... (though it works in the db)


SELECT * FROM `Folders` WHERE `sizecat`='{$sizecat}' AND `finalsize`='{$finalsize}' AND `color`='{$color}' AND `material`='{$material}' AND `totalsize`='{$totalsize}';")

If I would put it in, I'd put it in like this:


SELECT * FROM `Folders` WHERE `sizecat`='{$sizecat}' AND `finalsize`='{$finalsize}' AND `color`='{$color}' AND `material`='{$material}' AND `totalsize`='{$totalsize}' AND `price1` > '0';")

Bar2aYunie
06-26-2010, 06:53 PM
Okay, maybe this isn't the best or most practical or nicest solution, but at least it works and at least I have a solution. Lateron, I'm gonna work on improving the whole code and I'll keep looking for the best solution.

For now, I just wanted to share the solution with you ^.^



<?php

while($item=mysql_fetch_array($finalQuery)){
$base_m=5;
if ($item['col1'] > "0") {$item['col1'] = round ((($item['col1']+5) *1.85),0); $item['col01'] = $base_m*(ceil(($item['col1'])/$base_m)); }
if ($item['col2'] > "0") {$item['col2'] = round ((($item['col2']+5) *1.85),0); $item['col02'] = $base_m*(ceil(($item['col2'])/$base_m)); }
>?
// if you want, you can add what it should display by using the else statement. In this case, it just doesn't display anything
<td width="50%" align="center"><h4><?php echo "{$item['col01']}?></h4></td>
<td width="50%" align="center"><h4><?php echo "{$item['col02']}?></h4></td>


Thx for trying to help. And if anybody have any other suggestions, lemme know!

bluewalrus
06-27-2010, 05:32 AM
Your closing PHP tag is inverted. It should be ?> not >?

Bar2aYunie
06-27-2010, 11:06 AM
yeah of course, typo, lol

offshoredevelopment
06-28-2010, 10:13 AM
If you want to hide entry when value is 0, you will use dock icon.
In order to get rid of the dock icon, you must modify the file named 'Info.plist' inside the Application's package (i.e. Sherlock.app/Contents/Info.plist). Open this file in your favorite text editor and add the following section (if it's already present simply change the 0 to a 1 in the string tag:

NSUIElement
1

Bar2aYunie
06-28-2010, 05:15 PM
That doesn't look like php..... I'm not sure what you are saying...