Re: [PHP] Dynamically creating PHP before it is executed

2002-03-09 Thread Bogdan Stancescu

Why don't you try it? It works! Simply echo(TD 
CLASS=\$itemclass\.$$col./TD) and see what you get...

I'm probably very late with this reply, but just in case...

Bogdan

Jonathan Duncan wrote:

Sam,

The questions you write are good.  I am not sure why they can't.  I just
assumed that if I make lines of code like:

TD CLASS=\\$itemclass\\$$col/TD

and populate them like:

TD CLASS=$itemclass$column1/TD
TD CLASS=$itemclass$column2/TD
TD CLASS=$itemclass$column3/TD

that I would have to then evaluate them on a different page.  Am I
incorrect?

Thanks,
Jonathan Duncan


- Original Message -
From: Samuel Ottenhoff [EMAIL PROTECTED]
To: Jonathan Duncan [EMAIL PROTECTED]
Sent: Friday, March 08, 2002 10:23 PM
Subject: Re: [PHP] Dynamically creating PHP before it is executed


You make sense until the last paragraph.

It sounds like you are making this way more complicated than it need be.
Why write these out to files and then include them?  Why not just echo

your

results out to the browser?  Why can't all of this code be contained

within

one PHP page?

Sam



Jonathan Duncan [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

Bogdan,

Thank you for your comment, it actually made me think of a possible

solution

for something else I am working on.  However, it is just as I thought, I

am

being too vague.  I am most likely making my whole situation more
complicated than I need.  Another idea is just to do a select * and run
the whole shebang through an IF/ELSE series to determine which headers are
being used.  However, to remain on my current train of thought, here is a
snippet of my code:

  include(inc/dbconnect.inc);
  $sql = select columns from tablename where id=$someid;
  $sqlresult = mysql_query($sql, $connection) or die(Couldn't execute
query. (7));
  $columns_array = explode(,, $sqlresults['columns']);
  while (list($col) = each($columns_array)) {
 $sql = select coltitle from FreudColumns where colid='$col';
$result = mysql_query($sql, $connection) or die(Couldn't execute

query.

(12));
 $ch = mysql_fetch_array($result);
 // Set the column headers
 $headers .= TH CLASS=\hlink\$ch['coltitle']/TH;
// Set the item variables
 $setitemvar .= \$$col = \$isr['$col'];;
// Set the measurement columns
 $setitem .= TD CLASS=\\$itemclass\\$$col/TD;
  }
Afterwhich I write $headers to a file, $setitemvar to a file, $setitem to

a

file and call the page that is supposed to include these files I have just
writed so that the PHP code that I have just dynamically written will then
execute and the variables will be replaced.

Does this make any more sense?

Thank you,
Jonathan Duncan


Bogdan Stancescu [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

I don't quite understand why you chose such a complicated solution - I
may be missing something, in which case sorry for wasting your time. But
why don't you just dynamically build the select statement and then use
the whatever_fetch_array() -- and walk that array instead?

Just my 2c

Bogdan

Jonathan Duncan wrote:

I am trying to figure out a way to dynamically create some lines of PHP

code

and then have it executed.  This is because I want a page to display
different columns in a table depending on whatever link is clicked.

There

are hundreds of different combinations of column headings so I don't

want

to

make a different PHP page that is formated for each different

combination.

The column headings are stored in a database.

So far what I have come up with is to have a starting page, that takes

the

value of the link that is clicked, it queries the database for that

value

and then does a while statement to make all the TD's for the

different

columns.  Each TD is populated with a different variable, one for

each

column header.  Each iteration I append to a variable to hold all of

these

TD's.  Then I write the contents of that variable to a temporary

include

file and call the page that will display the table.  That table then
includes those TD's from the include file I wrote them to and

executes

the

PHP that runs another query on the database and fills in the variables

in

those TD's.

This seems like a lot of work.  Does what I am trying to do make sense

to

anyone?  Does anyone have any idea how to do this an easier way?

Thanks
Jonathan Duncan













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




[PHP] Dynamically creating PHP before it is executed

2002-03-08 Thread Jonathan Duncan

I am trying to figure out a way to dynamically create some lines of PHP code
and then have it executed.  This is because I want a page to display
different columns in a table depending on whatever link is clicked.  There
are hundreds of different combinations of column headings so I don't want to
make a different PHP page that is formated for each different combination.
The column headings are stored in a database.

So far what I have come up with is to have a starting page, that takes the
value of the link that is clicked, it queries the database for that value
and then does a while statement to make all the TD's for the different
columns.  Each TD is populated with a different variable, one for each
column header.  Each iteration I append to a variable to hold all of these
TD's.  Then I write the contents of that variable to a temporary include
file and call the page that will display the table.  That table then
includes those TD's from the include file I wrote them to and executes the
PHP that runs another query on the database and fills in the variables in
those TD's.

This seems like a lot of work.  Does what I am trying to do make sense to
anyone?  Does anyone have any idea how to do this an easier way?

Thanks
Jonathan Duncan



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




Re: [PHP] Dynamically creating PHP before it is executed

2002-03-08 Thread Bogdan Stancescu

I don't quite understand why you chose such a complicated solution - I 
may be missing something, in which case sorry for wasting your time. But 
why don't you just dynamically build the select statement and then use 
the whatever_fetch_array() -- and walk that array instead?

Just my 2c

Bogdan

Jonathan Duncan wrote:

I am trying to figure out a way to dynamically create some lines of PHP code
and then have it executed.  This is because I want a page to display
different columns in a table depending on whatever link is clicked.  There
are hundreds of different combinations of column headings so I don't want to
make a different PHP page that is formated for each different combination.
The column headings are stored in a database.

So far what I have come up with is to have a starting page, that takes the
value of the link that is clicked, it queries the database for that value
and then does a while statement to make all the TD's for the different
columns.  Each TD is populated with a different variable, one for each
column header.  Each iteration I append to a variable to hold all of these
TD's.  Then I write the contents of that variable to a temporary include
file and call the page that will display the table.  That table then
includes those TD's from the include file I wrote them to and executes the
PHP that runs another query on the database and fills in the variables in
those TD's.

This seems like a lot of work.  Does what I am trying to do make sense to
anyone?  Does anyone have any idea how to do this an easier way?

Thanks
Jonathan Duncan







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




Re: [PHP] Dynamically creating PHP before it is executed

2002-03-08 Thread Jonathan Duncan

Bogdan,

Thank you for your comment, it actually made me think of a possible solution
for something else I am working on.  However, it is just as I thought, I am
being too vague.  I am most likely making my whole situation more
complicated than I need.  Another idea is just to do a select * and run
the whole shebang through an IF/ELSE series to determine which headers are
being used.  However, to remain on my current train of thought, here is a
snippet of my code:

  include(inc/dbconnect.inc);
  $sql = select columns from tablename where id=$someid;
  $sqlresult = mysql_query($sql, $connection) or die(Couldn't execute
query. (7));
  $columns_array = explode(,, $sqlresults['columns']);
  while (list($col) = each($columns_array)) {
 $sql = select coltitle from FreudColumns where colid='$col';
$result = mysql_query($sql, $connection) or die(Couldn't execute query.
(12));
 $ch = mysql_fetch_array($result);
 // Set the column headers
 $headers .= TH CLASS=\hlink\$ch['coltitle']/TH;
// Set the item variables
 $setitemvar .= \$$col = \$isr['$col'];;
// Set the measurement columns
 $setitem .= TD CLASS=\\$itemclass\\$$col/TD;
  }
Afterwhich I write $headers to a file, $setitemvar to a file, $setitem to a
file and call the page that is supposed to include these files I have just
writed so that the PHP code that I have just dynamically written will then
execute and the variables will be replaced.

Does this make any more sense?

Thank you,
Jonathan Duncan


Bogdan Stancescu [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I don't quite understand why you chose such a complicated solution - I
 may be missing something, in which case sorry for wasting your time. But
 why don't you just dynamically build the select statement and then use
 the whatever_fetch_array() -- and walk that array instead?

 Just my 2c

 Bogdan

 Jonathan Duncan wrote:

 I am trying to figure out a way to dynamically create some lines of PHP
code
 and then have it executed.  This is because I want a page to display
 different columns in a table depending on whatever link is clicked.
There
 are hundreds of different combinations of column headings so I don't want
to
 make a different PHP page that is formated for each different
combination.
 The column headings are stored in a database.
 
 So far what I have come up with is to have a starting page, that takes
the
 value of the link that is clicked, it queries the database for that value
 and then does a while statement to make all the TD's for the different
 columns.  Each TD is populated with a different variable, one for each
 column header.  Each iteration I append to a variable to hold all of
these
 TD's.  Then I write the contents of that variable to a temporary
include
 file and call the page that will display the table.  That table then
 includes those TD's from the include file I wrote them to and executes
the
 PHP that runs another query on the database and fills in the variables in
 those TD's.
 
 This seems like a lot of work.  Does what I am trying to do make sense to
 anyone?  Does anyone have any idea how to do this an easier way?
 
 Thanks
 Jonathan Duncan
 
 
 






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




Re: [PHP] Dynamically creating PHP before it is executed

2002-03-08 Thread Jonathan Duncan

Sam,

The questions you write are good.  I am not sure why they can't.  I just
assumed that if I make lines of code like:

TD CLASS=\\$itemclass\\$$col/TD

and populate them like:

TD CLASS=$itemclass$column1/TD
TD CLASS=$itemclass$column2/TD
TD CLASS=$itemclass$column3/TD

that I would have to then evaluate them on a different page.  Am I
incorrect?

Thanks,
Jonathan Duncan


- Original Message -
From: Samuel Ottenhoff [EMAIL PROTECTED]
To: Jonathan Duncan [EMAIL PROTECTED]
Sent: Friday, March 08, 2002 10:23 PM
Subject: Re: [PHP] Dynamically creating PHP before it is executed


 You make sense until the last paragraph.

 It sounds like you are making this way more complicated than it need be.
 Why write these out to files and then include them?  Why not just echo
your
 results out to the browser?  Why can't all of this code be contained
within
 one PHP page?

 Sam



Jonathan Duncan [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Bogdan,

 Thank you for your comment, it actually made me think of a possible
solution
 for something else I am working on.  However, it is just as I thought, I
am
 being too vague.  I am most likely making my whole situation more
 complicated than I need.  Another idea is just to do a select * and run
 the whole shebang through an IF/ELSE series to determine which headers are
 being used.  However, to remain on my current train of thought, here is a
 snippet of my code:

   include(inc/dbconnect.inc);
   $sql = select columns from tablename where id=$someid;
   $sqlresult = mysql_query($sql, $connection) or die(Couldn't execute
 query. (7));
   $columns_array = explode(,, $sqlresults['columns']);
   while (list($col) = each($columns_array)) {
  $sql = select coltitle from FreudColumns where colid='$col';
 $result = mysql_query($sql, $connection) or die(Couldn't execute
query.
 (12));
  $ch = mysql_fetch_array($result);
  // Set the column headers
  $headers .= TH CLASS=\hlink\$ch['coltitle']/TH;
 // Set the item variables
  $setitemvar .= \$$col = \$isr['$col'];;
 // Set the measurement columns
  $setitem .= TD CLASS=\\$itemclass\\$$col/TD;
   }
 Afterwhich I write $headers to a file, $setitemvar to a file, $setitem to
a
 file and call the page that is supposed to include these files I have just
 writed so that the PHP code that I have just dynamically written will then
 execute and the variables will be replaced.

 Does this make any more sense?

 Thank you,
 Jonathan Duncan


 Bogdan Stancescu [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I don't quite understand why you chose such a complicated solution - I
  may be missing something, in which case sorry for wasting your time. But
  why don't you just dynamically build the select statement and then use
  the whatever_fetch_array() -- and walk that array instead?
 
  Just my 2c
 
  Bogdan
 
  Jonathan Duncan wrote:
 
  I am trying to figure out a way to dynamically create some lines of PHP
 code
  and then have it executed.  This is because I want a page to display
  different columns in a table depending on whatever link is clicked.
 There
  are hundreds of different combinations of column headings so I don't
want
 to
  make a different PHP page that is formated for each different
 combination.
  The column headings are stored in a database.
  
  So far what I have come up with is to have a starting page, that takes
 the
  value of the link that is clicked, it queries the database for that
value
  and then does a while statement to make all the TD's for the
different
  columns.  Each TD is populated with a different variable, one for
each
  column header.  Each iteration I append to a variable to hold all of
 these
  TD's.  Then I write the contents of that variable to a temporary
 include
  file and call the page that will display the table.  That table then
  includes those TD's from the include file I wrote them to and
executes
 the
  PHP that runs another query on the database and fills in the variables
in
  those TD's.
  
  This seems like a lot of work.  Does what I am trying to do make sense
to
  anyone?  Does anyone have any idea how to do this an easier way?
  
  Thanks
  Jonathan Duncan
  
  
  
 
 
 





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