Showing only number

Ask about a PHP problem here.
Post Reply
User avatar
leverkusen
Posts: 69
Joined: Sun Nov 18, 2012 10:09 pm
Location: Belgrade
Contact:

Showing only number

Post by leverkusen »

[syntax=php]echo '<td align="center" width="20"><p class="credit" maxlength="4" >'.$row['profit'].'$</p></td>'; [/syntax]
With this i got a profit number like this 343.34.
I want to display only 343 and .34 to be hidden, how can i do that? Hidden from the main page, not in the phpmyadmin table. :D
User avatar
leverkusen
Posts: 69
Joined: Sun Nov 18, 2012 10:09 pm
Location: Belgrade
Contact:

Re: Showing only number

Post by leverkusen »

And yes one more thing, here i dont know how to show numbers within the design.
It shows when i do with this
[syntax=php]$profit = $row['profit'] ;
$ulog = $row['ulog'] ;
echo $row['profit'] * $row['ulog'];[/syntax]
but not with this
[syntax=php]if($row['status']==1)echo '<td align="center"<td height="21"><font size="2" style=color:limegreen>+'.$row['profit'].'$</td>';
[/syntax]
http://prntscr.com/7huy7q
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Showing only number

Post by jacek »

leverkusen wrote:I want to display only 343 and .34 to be hidden, how can i do that? Hidden from the main page, not in the phpmyadmin table. :D
To make it show only the whole number part you can use round()
[syntax=php]echo round(343.34);[/syntax]
will output 343

For the other problem can you post a bit more of the code for the one that does not work? It could be something further up.
Image
User avatar
leverkusen
Posts: 69
Joined: Sun Nov 18, 2012 10:09 pm
Location: Belgrade
Contact:

Re: Showing only number

Post by leverkusen »

1. well i need to fit in that round in here but i dont know how because i alwas get some error.
echo '<td align="center" width="20"><p class="credit" maxlength="4" >'.$row ['profit'].'$</p></td>';
2. here is the whole code, last 3 rows are correct and i want to show that result inhere

[syntax=php]if($row['status']==1)echo '<td align="center"<td height="21"><font size="2" style=color:limegreen>+'.$row['profit'].'$</td>';
else echo '<td align="center"<td height="21"><font size="2">'.$row['profit'].'$</td>'; [/syntax]

[syntax=php]$result = mysql_query("select * from clanovi_njihovi_parovi where racun='$id' and 'status'<>2 order by id;");

if(mysql_affected_rows()>0){
echo '
<tr align="center" bgcolor=#ffffff><td height="20"
<td width="12%"><p class="user">date</p>
<td width="12%"><p class="user">time</p>
<td width="24%"><p class="user">match</p>
<td width="8%"><p class="user">tip</p>
<td width="10%"><p class="user">odds</p>
<td width="8%"><p class="user">stake</p>
<td width="8%"><p class="user">status</p>
<td width="10%"><p class="user">profit</p></td></tr>';
$br=0;
while($row = mysql_fetch_array($result)){
if($br%2==0)echo '<tr onmouseover="this.style.backgroundColor=\'#eaffe7\';" onmouseout="this.style.backgroundColor=\'#e7e7e7\';" bgcolor="#e7e7e7"><align="center" class="odd">';
else echo '<tr onmouseover="this.style.backgroundColor=\'#eaffe7\';" onmouseout="this.style.backgroundColor=\'#ffffff\';" bgcolor="#ffffff"><align="center">';
$br++;
echo '<td align="center" height="21">'.$row['datum'].'</td>';
echo '<td align="center" height="21">'.$row['vrijeme'].'</td>';
echo '<td align="center" height="21"><font style size="2"><a target="_blank" href="'.$row['link'].'">'.$row['tim1'].' - '.$row['tim2'].'</a></td>';
echo '<td align="center" <font style=color:dodgerblue <td height="21">'.$row['tip'].'</font></td>';
echo '<td align="center" <font style=color:dodgerblue <td height="21">'.$row['kvota'].'</font></td>';
echo '<td align="center" <font> <p class="credit" <td height="21">'.$row['ulog'].'$</font></p></td>';
if($row['status']=="")echo '<td align="center"<td height="21"><img src="images/n1ec8o.gif"/></td>';
else if($row['status']==1)echo '<td align="center"<td height="21"><img src="images/win.gif"/></td>';
else echo '<td align="center"<td height="21"><img src="images/pao.png"/></td>';
if($row['status']==1)echo '<td align="center"<td height="21"><font size="2" style=color:limegreen>+'.$row['profit'].'$</td>';
else echo '<td align="center"<td height="21"><font size="2">'.$row['profit'].'$</td>';
echo '</tr>';
$profit = $row['profit'] ;
$ulog = $row['ulog'] ;
echo $row['profit'] * $row['ulog'];[/syntax]
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Showing only number

Post by jacek »

You want to use round() on the profit
[syntax=php]round($row['profit'])[/syntax]
if that doesn't work can you post the code that you tried and the error it gave?

In one example you multiply profit by ulog and in the other you don't. Could that be something to do with it?
It might help to print out the variables and see if they have the values you expect. You can use var_dump to show the value in detail, have a look at http://php.net/var_dump
Image
Post Reply