Re: [PHP] Function passed as argument to function

2002-12-01 Thread Jeffrey B. Ferland
  For reference, see http://autocracy.homelinux.org/template.php and
  http://autocracy.homelinux.org/error.php

 Unless you have a good reason to do otherwise please post your code here.
 People would be less inclined to help if they have to go about clicking on
 links to see what your problem is.

Noted

 1) Do you really mean list_writings(poetry), or did you in fact mean
 list_writings($poetry)?

list_writings(poetry); or more accurately std_layout(Recent Writings,
list_writings(poetry)); I've also tried that using various methods of
quoting for the list_writings(poetry) and also doing strange things like
making anonymous functions and defining the function as a variable and
what-not.

 2) How did you conclude that? Did you check that
 list_writings(poetry)/list_writings($poetry) gives the correct result? IE
 echo list_writings(poetry)/list_writings($poetry) ?

list_writings(poetry) simply spits out the output. 'echo
list_writings(poetry)' was not designed as the proper way to use the
command. Here is the current code for the function (in its half-complete but
working state with mysql_connect() and mysql_select_db replaced with generic
variables for public consumption), and also the std_layout function
following:

function list_writings($table) {
$db_link = mysql_connect($host, $user, $pw)
or die(DB connect failure);
mysql_select_db ($db_name) ;
$query = SELECT wid, title, description FROM $table ORDER BY wid DESC LIMIT
15;
$result = mysql_query($query, $db_link);
while ($row = mysql_fetch_row ($result))
{
print a href=\/poetry.php?wid=$row[0]\$row[1]/abr;
};
};

function std_layout($ltitle, $ltext) {
echo 
table width=\100%\ align=\top\
  tr
td valign=\top\
  table style=\border-top: 1px solid #00; border-right: 1px solid
#00\ width=\175\
tr
  td bgcolor=#B0C4DE valign=\top\
nbsp; $ltitle
  /td
/tr
tr
  td
$ltext
  /td
/tr
  /table
/td
td valign=\top\ ;
} ;

Basically, I want std_layout to be able to take either straight text as an
argument or the output of a function (even if it's through a mid-point such
as a variable). That failing I'm going to have to admit a design flaw to
myself and re-work the code...

-Jeff
SIG: HUP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Function passed as argument to function

2002-12-01 Thread John W. Holmes
[snip]
  2) How did you conclude that? Did you check that
  list_writings(poetry)/list_writings($poetry) gives the correct
result?
 IE
  echo list_writings(poetry)/list_writings($poetry) ?
 
 list_writings(poetry) simply spits out the output. 'echo
 list_writings(poetry)' was not designed as the proper way to use the
 command. Here is the current code for the function (in its
half-complete
 but
 working state with mysql_connect() and mysql_select_db replaced with
 generic
 variables for public consumption), and also the std_layout function
 following:
 
 function list_writings($table) {
 $db_link = mysql_connect($host, $user, $pw)
 or die(DB connect failure);
 mysql_select_db ($db_name) ;
 $query = SELECT wid, title, description FROM $table ORDER BY wid DESC
 LIMIT
 15;
 $result = mysql_query($query, $db_link);
 while ($row = mysql_fetch_row ($result))
 {
 print a href=\/poetry.php?wid=$row[0]\$row[1]/abr;
 };
 };

So if you want the result returned, take out that print call. Assign it
all to a variable and return it.

$retval .= a href=\/poetry.php?wid=$row[0]\$row[1]/abr;

and 

return($retval);

at the end of the function. Then you'll be able to do what you want. 

---John Holmes... 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Function passed as argument to function

2002-11-30 Thread Jason Wong
On Sunday 01 December 2002 03:54, Jeffrey B.Ferland wrote:
 std_layout(Title here, list_writings(poetry))

 both std_layout and list_writings are user-defined functions. std_layout()
 echo's the two arguments that it takes at select points in its execution. I
 want to the output of list_writings()  to be an argument for std_layout().

Hmm, what's the problem then?

Functions take any valid expressions as arguments. If list_writings() returns 
a valid expression then you should have no problems at all.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Play Rogue, visit exotic locations, meet strange creatures and kill them.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Function passed as argument to function

2002-11-30 Thread Jeffrey B . Ferland
On Saturday 30 November 2002 03:14 pm, you wrote:
 On Sunday 01 December 2002 03:54, Jeffrey B.Ferland wrote:
  std_layout(Title here, list_writings(poetry))
 
  both std_layout and list_writings are user-defined functions.
  std_layout() echo's the two arguments that it takes at select points in
  its execution. I want to the output of list_writings()  to be an argument
  for std_layout().

 Hmm, what's the problem then?

 Functions take any valid expressions as arguments. If list_writings()
 returns a valid expression then you should have no problems at all.

For reference, see http://autocracy.homelinux.org/template.php and 
http://autocracy.homelinux.org/error.php

template.php is the proper layout, and uses the same code as 
error.php, with the exception that LEFT SIDE TEXT has been replaced with 
'list_writings(poetry)'. Note that the output from that function occurs where 
it was placed within the code, not where it was called to...

Basically, instead of the output from list_writings(poetry) being passed to 
the function, it simply executes.

-Jeff
SIG: HUP

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Function passed as argument to function

2002-11-30 Thread Jason Wong
On Sunday 01 December 2002 04:43, Jeffrey B.Ferland wrote:
 For reference, see http://autocracy.homelinux.org/template.php and
 http://autocracy.homelinux.org/error.php

Unless you have a good reason to do otherwise please post your code here. 
People would be less inclined to help if they have to go about clicking on 
links to see what your problem is.

 template.php is the proper layout, and uses the same code as
 error.php, with the exception that LEFT SIDE TEXT has been replaced with
 'list_writings(poetry)'. Note that the output from that function occurs
 where it was placed within the code, not where it was called to...


1) Do you really mean list_writings(poetry), or did you in fact mean 
list_writings($poetry)?

 Basically, instead of the output from list_writings(poetry) being passed to
 the function, it simply executes.

2) How did you conclude that? Did you check that 
list_writings(poetry)/list_writings($poetry) gives the correct result? IE 
echo list_writings(poetry)/list_writings($poetry) ?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
You who hate the Jews so, why did you adopt their religion?
-- Friedrich Nietzsche, addressing anti-semitic Christians
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php