Current location: Hot Scripts Forums » Programming Languages » PHP » Help with php value passing


Help with php value passing

Reply
  #11 (permalink)  
Old 04-01-06, 05:13 PM
david510 david510 is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
WOWOW!

Worked great!! You guys ROCK!!

I use the following functio to do a conditional checking.

PHP Code:

function myfunc($myvar)

{
  if ((
$myvar >= "00.00") && ($myvar <= "04.00"))
   return(
White);

  if ((
$myvar "04.00") && ($myvar <= "06.00") )
   return(
Yellow);

  if (
$myvar "06.00")
   return(
Red);

  return;

When I pass absolute values to myfunc($myvar) like setting $myvar="00.87" the function works correctly and for this while is returned.

If after getting a value like this from a url (value returned being like eg 00.87) it is not returning White but always Red. No matter what the value is. If I do echo $varload it idsplays 00.87. Any idea?

PHP Code:

$varload file_get_contents("http://domain.com/file.php"); 

Also I need to execute include("http://domain/test.php"); inside the echo command as shown below. Can this be done?

PHP Code:

echo '<table border="1" bgcolor='.$var1.'>

<tr>
<td>include("http://domain.com/test.php")</td>

<td>Row 1 Cell 2</td></tr>

<tr><td>Row 2 Cell 1</td><td>Row 2 Cell 2</td></tr>
</table>'


Last edited by david510; 04-01-06 at 06:11 PM.
Reply With Quote
  #12 (permalink)  
Old 04-02-06, 03:15 AM
gorivo's Avatar
gorivo gorivo is offline
Newbie Coder
 
Join Date: Mar 2006
Location: Lithuania
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
use this:

PHP Code:

function myfunc($myvar

  if ((
$myvar >= 0) && ($myvar <= 4)) 
   return 
"White"

  if ((
$myvar 4) && ($myvar <= 6) ) 
   return 
"Yellow"

  if (
$myvar 6
   return 
"Red"

  return 
false

Reply With Quote
  #13 (permalink)  
Old 04-02-06, 03:18 AM
gorivo's Avatar
gorivo gorivo is offline
Newbie Coder
 
Join Date: Mar 2006
Location: Lithuania
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
if you want to insert only the output of http://domain.com/test.php into echo, do this:

PHP Code:

<?php


echo '<table border="1" bgcolor='.$var1.'>
<tr>
<td>'
.file_get_contents("http://domain.com/test.php").'</td>

<td>Row 1 Cell 2</td></tr>

<tr><td>Row 2 Cell 1</td><td>Row 2 Cell 2</td></tr>
</table>'


?>
Reply With Quote
  #14 (permalink)  
Old 04-02-06, 04:12 AM
david510 david510 is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
I found out naother way to pass php variable to html

<tr><td bgcolor='<?=$abc?>'>
Reply With Quote
  #15 (permalink)  
Old 04-04-06, 02:18 PM
david510 david510 is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
A small issue...

I am geting the contents of a file from a remote server like this.

PHP Code:

function func1()

{
  
$var1 file_get_contents("http://domain.com/absload.php");
  echo 
"Value of  var1 inside the func : $var1 ###";
  return 
$var1;


I call this finction like this

PHP Code:



$var2 
func1();
echo 
"Value of  var1 inside the func : $var2 ###" 
when this is executed and I print both prints the same value but lots of spaces in between exactly like this ( without ===).

================================
Value of var1 inside the func :

2.85



###
================================

How can I get rid of the spaces becasue I need this value to use in another function for using conditional operation. I need this to be displayed like this.


================================
Value of var1 inside the func :2.85 ###
================================
Reply With Quote
  #16 (permalink)  
Old 04-05-06, 11:14 AM
david510 david510 is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Ok I managed to get this corrected myself. Thank you!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Javascript Variable to PHP watadude PHP 4 01-15-11 06:44 PM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP / Graphic Developers someotherguy582 Job Offers & Assistance 1 06-05-05 07:40 PM
Passing a PHP variable in Javascript??? todayscoffee JavaScript 2 01-08-05 09:45 AM
Passing a PHP variable in Javascript??? todayscoffee PHP 2 01-04-05 01:56 PM


All times are GMT -5. The time now is 07:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.