Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  agyat : (24 May 2013 - 05:15 PM) O Dear, Where Are You? Without Your Words This Sb Is ..
@  agyat : (23 May 2013 - 01:23 AM) Wow! Mr. Sb Back Home.
@  OpaQue : (23 May 2013 - 12:44 AM) Ting
@  OpaQue : (24 April 2013 - 02:44 PM) I guess, Time to run Mycent script.
@  OpaQue : (24 April 2013 - 02:43 PM) wow.. not much spam. except habatt posting lot of links.. :P
@  yordan : (23 April 2013 - 01:04 PM) You're welcome, agyat. Nice to have been helpful. Second lesson: try full words, "you" instead of "EW".
@  agyat : (23 April 2013 - 05:03 AM) @YORDAN: tHANK EW FOR YOUR FIRST LESSON.   :D
@  yordan : (22 April 2013 - 09:43 PM) @agyat : "why don't you help me", or "please help me", or "please teach us"
@  yordan : (22 April 2013 - 09:42 PM) welcome back, velma
@  velma : (22 April 2013 - 07:51 AM) **yawns** Good to be back, wonder what is going on here :)
@  agyat : (22 April 2013 - 03:50 AM) Oh! so, why don't help me learn english..
@  yordan : (21 April 2013 - 08:38 PM) The goal mentioned by shiu : "learning english, learning computer"
@  agyat : (21 April 2013 - 06:31 PM) WHAT GOAL?
@  yordan : (20 April 2013 - 10:39 AM) yes, that's our goal. simultaneouly learning English and teaching/learning computer using.
@  shiyu : (20 April 2013 - 07:30 AM) learning english,learning computer
@  yordan : (19 April 2013 - 01:11 PM) Oh, I see, it's just a trick in order to force people looking at your texte. Somehow smart, maybe.
@  agyat : (19 April 2013 - 02:54 AM) And of course I know it is not SEO friendly.
@  agyat : (19 April 2013 - 02:52 AM) There may be two possible answers for that ....


1) Shout was posted using mobile keypad.

2) To force people read content carefully and/or with more concentration.
@  agyat : (19 April 2013 - 02:49 AM) There may be two possible answers for that ....
@  yordan : (18 April 2013 - 09:35 PM) however, why this mixing of capital letters in the middle of your text?

Replying to Php Math Error


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

TavoxPeru

Posted 02 October 2007 - 04:30 AM

What I want is here is one column: 5+5 and I simply:
echo($row['Column']);
and that displayes 10 not 5+5. So the echo is:
10
I don't really know how else to say it. Im sorry if I am still a little confusing.
Thanks,
Sparkx

Well, it took me more time than i expected but finally i got the solution, the way i got it is with the help of the php eval() function. What this function do is to evaluate the string given as a parameter as it is PHP code so you can execute it, i think it is very similar to the javascript eval() function.

So please try the following code and tell us if it is what you want:

<?php
eval("$"."variable"."=".$row['Column'].";");
echo "\$variable is = $variable";
//echo "&lt;script>var var1=eval('$variable'); alert(var1);</script>";
?>
The last line -in case you need it- shows the use of the Javascript eval() function, simply uncomment this line to see it in action.

Best regards,

develCuy

Posted 02 October 2007 - 02:48 AM

What I want is here is one column: 5+5 and I simply:
echo($row['Column']);
and that displayes 10 not 5+5. So the echo is:
10
I don't really know how else to say it. Im sorry if I am still a little confusing.
Thanks,
Sparkx


If you want PHP math:
echo $row['Column']+5;

If you want PHP + MySQL math:
$rs = mysql_query("select 5+".5);
print_r(mysql_fetch_row($rs));

If you want MYSQL math:
Select 5+5

More on MySQL math.

Blessings!

sparkx

Posted 01 October 2007 - 10:55 PM

What I want is here is one column: 5+5 and I simply:
echo($row['Column']);
and that displayes 10 not 5+5. So the echo is:
10
I don't really know how else to say it. Im sorry if I am still a little confusing.
Thanks,
Sparkx

TavoxPeru

Posted 30 September 2007 - 08:52 AM

I'm not really sure what you want but if it is to simply get the results of a math operation try this:

<?php
// math with 2 columns
$sql="select (numeric_col1+numeric_col2) as result from table";
$row=mysql_query($sql);
$rs_row=mysql_fetch_array($row);
echo $rs_row["result"];
?>
The above code only works if you want to perform the math operation with two columns, so, tell me, your entrie is like this or you have it in one column only.

Also you can use the MySql CAST() function.

Best regards,

sparkx

Posted 29 September 2007 - 11:18 PM

I cant get php to do simple math. Anyway I need to run a math problem from the mysql database (dont ask why). So lets say I have an entrie: 5+5. I get it from my db then eval it but nothing happens? How could I make it so that it runs the 5+5 rather then just displaying it?
Thanks,
Sparkx
Also: I have no clue if it is just my browser or what but my post breaks to boarder for some odd reason?

Review the complete topic (launches new window)