Re: [PHP] dynamic arraynames

2002-12-02 Thread Floyd Baker


Just want to thank everyone and tell how it finally came out...

I was making way to much of this and went into difficult concepts too
quickly.  That's where the problem came from.  Trying to build on
earlier mistakes.   

We already had an array for the column names so a suggestion that I
use one single array for all the data columns works out the best.
Now I'm unwinding that one long array according to how many name
fields there are in each row.  As each process is done, the fields are
there in the original column order, no matter how big the x-y grid is.

The data from the 'basic' column arrays is also going to be included
in the single array too.

I'm not a wiz by any means so creating the best application 'method'
can be rough no matter what I know about the individual functions.
The *single* array just never dawned on me.  Thanks for the help...
:-)  

Floyd 













On Fri, 29 Nov 2002 11:47:56 -, you wrote:

 -Original Message-
 From: Floyd Baker [mailto:[EMAIL PROTECTED]]
 Sent: 28 November 2002 17:09
 
OK, I think I'm finally beginning to understand what you're up to, and it seems to me 
everyine's been making rather heavy weather of it so far!

 The user's choice is made from a drop down list of available items,
 prior to running the routine itself.  The choices are predetermined
 and kept in a personal table to be called by the routine.  This part
 is finished to the point of putting the needed column names at the top
 of the input columns on the form.  The choices are fixed spellings to
 match formula if-then's, etc.

If this is the case, couldn't you use 2-dimensional arrays with the column names as 
the first dimension, and the values relating to it in the second dimension?

So you'd have something like 

  $user['colour'][0]   $user['hobby'][0]   $user['etc'][0]
  $user['colour'][1]   $user['hobby'][1]   $user['etc'][1]
  $user['colour'][2]   $user['hobby'][2]   $user['etc'][2]
  $user['colour'][3]   $user['hobby'][3]   $user['etc'][3]

etc.

Anyway, going back to your forms:

 if ($start_button==1)
  {
  print form action=$PHP_SELF method=get;
  print Input the following information;
  // these are your fixed cells and they now contain user input
print Name: input type=text name=name value=\$name\ 
 size=20br;
print Temp: input type=text name=temp value=\$temp\ 
 size=20br;
print Time: input type=text name=time value=\$time\ 
 size=20br;
print Offset: input type=text name=offset value=\$offset\
 size=20br;
  print Input the names of the desired additional cells in the spaces
 provided.;
  // this is where your user will name the cells he asked to create
  for($i=1;$i=$additional_cells;$i++)
   {
   print $i input type=text name=user_added[$i] size=20br;
   }

OK, this looks good -- it will give you your array of column names.   But you really 
should quote all those attributes, so:

  print $i input type=\text\ name=\user_added[$i]\ size=\20\br;

The next bit is where I'd do the clever stuff to build the 2-dimensional array:

  Name  Temp  Time  OffsetEtc.  As needed...
  process 1[input]   [input]   [input]   [input]   [inputs]
  process 2[input]   [input]   [input]   [input]   [inputs]
  process 3[input]   [input]   [input]   [input]   [inputs]
  process 4[input]   [input]   [input]   [input]   [inputs]
 
  Right now, for the three *basic* columns, I have the lines 
 below in a
  'while' loop.
 
  INPUT TYPE='text' NAME='temp[]' VALUE='$temp' SIZE='10'
  MAXLENGTH='10'
  INPUT TYPE='text' NAME='time[]' VALUE='$time' SIZE='10'
  MAXLENGTH='10'
  INPUT TYPE='text' NAME='offs[]' VALUE='$offs' SIZE='10'
  MAXLENGTH='10'

So, you just need additional lines in your while loop to add the entries for the user 
columns, named in such a way that you'll get back the 2-dimensional array I described 
earlier.  As you already have those column namers in the $user_added[] array built 
above, we can do it like this:

  foreach ($user_added as $user_col):
echo input type='text' name=\user['$user_col'][]\ size='10' 
maxlength='10';
  endforeach;

and, bingo, you have your user's input being submitted into a 2-dimensional array 
indexable by column name and row number.

(Actually, to be absolutely sure all the row numbers match, I'd be outputting those 
into the form field names as well.)

Additionally, having gone this far I'd consider doing the same sort of thing with 
your standard columns, something like this:

   $std_cols = array('temp', 'time', 'offs');

   // now fill the $user_added[] array from database or wherever

   echo form ..;

   
   for ($n=0; $nROWS_NEEDED; $n++):

  foreach ($std_cols as $col_id):
 echo input type='text' name=\$col_id[$n]\ size='10' ;
  endforeach;

  foreach ($user_added as $col_id):
 echo input type='text' name=\user['$col_id'][$n]\ size='10' ;
  endforeach;

   endfor;

You could even 2-dimensionalize your standard columns, so you 

RE: [PHP] dynamic arraynames

2002-11-29 Thread Ford, Mike [LSS]
 -Original Message-
 From: Floyd Baker [mailto:[EMAIL PROTECTED]]
 Sent: 28 November 2002 17:09
 
OK, I think I'm finally beginning to understand what you're up to, and it seems to me 
everyine's been making rather heavy weather of it so far!

 The user's choice is made from a drop down list of available items,
 prior to running the routine itself.  The choices are predetermined
 and kept in a personal table to be called by the routine.  This part
 is finished to the point of putting the needed column names at the top
 of the input columns on the form.  The choices are fixed spellings to
 match formula if-then's, etc.

If this is the case, couldn't you use 2-dimensional arrays with the column names as 
the first dimension, and the values relating to it in the second dimension?

So you'd have something like 

  $user['colour'][0]   $user['hobby'][0]   $user['etc'][0]
  $user['colour'][1]   $user['hobby'][1]   $user['etc'][1]
  $user['colour'][2]   $user['hobby'][2]   $user['etc'][2]
  $user['colour'][3]   $user['hobby'][3]   $user['etc'][3]

etc.

Anyway, going back to your forms:

 if ($start_button==1)
  {
  print form action=$PHP_SELF method=get;
  print Input the following information;
  // these are your fixed cells and they now contain user input
print Name: input type=text name=name value=\$name\ 
 size=20br;
print Temp: input type=text name=temp value=\$temp\ 
 size=20br;
print Time: input type=text name=time value=\$time\ 
 size=20br;
print Offset: input type=text name=offset value=\$offset\
 size=20br;
  print Input the names of the desired additional cells in the spaces
 provided.;
  // this is where your user will name the cells he asked to create
  for($i=1;$i=$additional_cells;$i++)
   {
   print $i input type=text name=user_added[$i] size=20br;
   }

OK, this looks good -- it will give you your array of column names.   But you really 
should quote all those attributes, so:

  print $i input type=\text\ name=\user_added[$i]\ size=\20\br;

The next bit is where I'd do the clever stuff to build the 2-dimensional array:

  Name  Temp  Time  OffsetEtc.  As needed...
  process 1[input]   [input]   [input]   [input]   [inputs]
  process 2[input]   [input]   [input]   [input]   [inputs]
  process 3[input]   [input]   [input]   [input]   [inputs]
  process 4[input]   [input]   [input]   [input]   [inputs]
 
  Right now, for the three *basic* columns, I have the lines 
 below in a
  'while' loop.
 
  INPUT TYPE='text' NAME='temp[]' VALUE='$temp' SIZE='10'
  MAXLENGTH='10'
  INPUT TYPE='text' NAME='time[]' VALUE='$time' SIZE='10'
  MAXLENGTH='10'
  INPUT TYPE='text' NAME='offs[]' VALUE='$offs' SIZE='10'
  MAXLENGTH='10'

So, you just need additional lines in your while loop to add the entries for the user 
columns, named in such a way that you'll get back the 2-dimensional array I described 
earlier.  As you already have those column namers in the $user_added[] array built 
above, we can do it like this:

  foreach ($user_added as $user_col):
echo input type='text' name=\user['$user_col'][]\ size='10' 
maxlength='10';
  endforeach;

and, bingo, you have your user's input being submitted into a 2-dimensional array 
indexable by column name and row number.

(Actually, to be absolutely sure all the row numbers match, I'd be outputting those 
into the form field names as well.)

Additionally, having gone this far I'd consider doing the same sort of thing with your 
standard columns, something like this:

   $std_cols = array('temp', 'time', 'offs');

   // now fill the $user_added[] array from database or wherever

   echo form ..;

   
   for ($n=0; $nROWS_NEEDED; $n++):

  foreach ($std_cols as $col_id):
 echo input type='text' name=\$col_id[$n]\ size='10' ;
  endforeach;

  foreach ($user_added as $col_id):
 echo input type='text' name=\user['$col_id'][$n]\ size='10' ;
  endforeach;

   endfor;

You could even 2-dimensionalize your standard columns, so you get:

   $std['temp'][0]   $std['time'][0]   $std['offs'][0]
   $std['temp'][1]   $std['time'][1]   $std['offs'][1]

etc., with the corresponding form fields being written using:

  foreach ($std_cols as $col_id):
 echo input type='text' name=\std['$col_id'][$n]\ size='10' ;
  endforeach;

And, then, of course, you might well wonder why you should bother having two separate 
sets of very similar arrays, when you could merge them and just keep track of how many 
are standard ones (with the rest automatically treated as user added ones). So you'd 
start off something like:

   $cols = array('temp', 'time', 'offs');
   define('N_STD_COLS', 3);

and build from there -- but I leave that as an exercise for the reader!!!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,

Re: [PHP] dynamic arraynames

2002-11-28 Thread Hugh Danaher
Floyd,
I thought about this some and started noodling out a solution for you, but
have a few questions before I go any farther on this.
1. The part about users inputting their own column headers is relatively
straight forward.  Something like this should work:

?php
if (!isset($start_button))
{
print form action=$PHP_SELF method=get;
print Input the following information;
 // these are your fixed cells
print Name: input type=text name=name size=20br;
print Temp: input type=text name=temp size=20br;
print Time: input type=text name=time size=20br;
print Offset: input type=text name=offset size=20br;
 // User inputs the number of additional cells needed
  print Input number of additional cells needed: input type=text
name=additional_cells size=20br;
  print input type=hidden name=start_button value=1;
  print input type=submit value=\ Hit it! \;
  print /form;
  }
if ($start_button==1)
 {
 print form action=$PHP_SELF method=get;
 print Input the following information;
 // these are your fixed cells and they now contain user input
   print Name: input type=text name=name value=\$name\ size=20br;
   print Temp: input type=text name=temp value=\$temp\ size=20br;
   print Time: input type=text name=time value=\$time\ size=20br;
   print Offset: input type=text name=offset value=\$offset\
size=20br;
 print Input the names of the desired additional cells in the spaces
provided.;
 // this is where your user will name the cells he asked to create
 for($i=1;$i=$additional_cells;$i++)
  {
  print $i input type=text name=user_added[$i] size=20br;
  }
 print input type=hidden name=additional_cells value=\$additional_cells\
;
 print input type=hidden name=start_button value=2;
 print input type=submit value=\ Hit it! \;
 print /form;
 }
if ($start_button==2)
   {
print $name.br.$temp.br.$time.br.$offset.br;
for($i=1;$i=$additional_cells;$i++)
{
print user cell .$i. .$user_added[$i].br;
}
}
?


2. Now comes the tricky part, and the part I'm unsure about.  You can
convert the user input in the above so that it becomes the names of the
input cells, or you can leave them in a numeric array.  Leaving them in a
numeric array will be easier to deal with later.
Also, other than the display of a table, what do you want the user input
for?  If you're planning on doing any data manipulation, then your coding
will get a bit hairy because you won't know what relation the user input
data has to your standard data (name, time, temp and offset).  Finally, if
you're planning on storing the data in a database table, each table will
need to be created on the fly--it can be done, but if you're struggling with
this, it'll take you some time to get the back end working.

Hope this helps,
Hugh

- Original Message -
From: Floyd Baker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: 'Hugh Danaher' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, November 27, 2002 5:24 PM
Subject: Re: [PHP] dynamic arraynames




 Well I might be in the wrong place.  I've also asked in the HTML list
 now too but I'm still stuck and need some help.

 This is pretty much as clear as I can make it.  I'm up against a
 mental block and even if it's as clear as glass to others I'm dead in
 the water and would appreciate some pointers.  I have a bunch of
 pieces but can't seem to string them together enough to make it work.

 Just trying to build an x-y array of data input fields and then send
 them recursive to be used further down the program.

 I can do this fine with a fixed number of columns and rows of user
 input but I cannot figure out how to make this happen using a variable
 number of columns.  I'm a complete array amateur and would appreciate
 a little assistance...

 I want it to look something like this:

 Name  Temp  Time  OffsetEtc.  As needed...
 process 1[input]   [input]   [input]   [input]   [inputs]
 process 2[input]   [input]   [input]   [input]   [inputs]
 process 3[input]   [input]   [input]   [input]   [inputs]
 process 4[input]   [input]   [input]   [input]   [inputs]

 Right now, for the three *basic* columns, I have the lines below in a
 'while' loop.

 INPUT TYPE='text' NAME='temp[]' VALUE='$temp' SIZE='10'
 MAXLENGTH='10'
 INPUT TYPE='text' NAME='time[]' VALUE='$time' SIZE='10'
 MAXLENGTH='10'
 INPUT TYPE='text' NAME='offs[]' VALUE='$offs' SIZE='10'
 MAXLENGTH='10'

 But when it comes to adding additional columns that a user
 determines are needed, I am lost.  Users might want to add 0, or 4, or
 10 additional items...  I would like only that number of usable
 input columns be on the input-form, identified for what they contain,
 and then be passed to the next page

 Again, many thanks in advance.

 Floyd






 On Sun, 24 Nov 2002 23:55:56 -0500, you wrote:

 I'm sorry, but I'm still confused. Can you show us a sample of the data
 in the database and what you want the resulting form to look like for
 that data? Maybe that'll help.
 
 ---John

Re: [PHP] dynamic arraynames

2002-11-28 Thread Floyd Baker


The user's choice is made from a drop down list of available items,
prior to running the routine itself.  The choices are predetermined
and kept in a personal table to be called by the routine.  This part
is finished to the point of putting the needed column names at the top
of the input columns on the form.  The choices are fixed spellings to
match formula if-then's, etc.   The use is for data manipulation and
so proper tracking of name/data is important in that regard, but the
final output figures go to the same categories in all cases so those
tables are fixed.  

The personal list table is to be called on the action page for keeping
the arrays in their proper order and usage.  The original idea was
that the list would be used somehow for creating the required
$_request's etc. 

But as you say, the tricky part is the naming of the columns, as we do
with the 'basic' column arrays.  I don't know if this can be done.
Thought it might be possible with 'dot' adds of functions or some such
to command lines built on the fly but haven't been able to make it
happen.  

But putting together what you and others are saying is giving me good
thoughts. :-)   Although I am still not sure how to code all of this,
much less express it, I am getting the idea that all 'columns' would
have the same array name and that the position of the data within that
single array will be the determining factor as to where it is applied.

That is if we need 3 user columns and 4 rows we will end up with a
single array of 12 values...  The three columns' fields would be
arranged as 1-4-7-10, 2-5-8-11 and 3-6-9-12.  

That should work nicely.  The column name list determines the number
of fields per row and the rest is automatic.  Perhaps I was going off
the deep end before but this method seems much less involved.  Anyone
see a problem with doing it this way?  

Many thanks to all and I apologize for the verbosity.  

Floyd
  



On Thu, 28 Nov 2002 01:28:48 -0800, you wrote:

Floyd,
I thought about this some and started noodling out a solution for you, but
have a few questions before I go any farther on this.
1. The part about users inputting their own column headers is relatively
straight forward.  Something like this should work:

?php
if (!isset($start_button))
{
print form action=$PHP_SELF method=get;
print Input the following information;

 // these are your fixed cells
print Name: input type=text name=name size=20br;
print Temp: input type=text name=temp size=20br;
print Time: input type=text name=time size=20br;
print Offset: input type=text name=offset size=20br;

 // User inputs the number of additional cells needed
  print Input number of additional cells needed: input type=text
 name=additional_cells size=20br;
  print input type=hidden name=start_button value=1;
  print input type=submit value=\ Hit it! \;
  print /form;
  }


if ($start_button==1)
 {
 print form action=$PHP_SELF method=get;
 print Input the following information;
 // these are your fixed cells and they now contain user input
   print Name: input type=text name=name value=\$name\ size=20br;
   print Temp: input type=text name=temp value=\$temp\ size=20br;
   print Time: input type=text name=time value=\$time\ size=20br;
   print Offset: input type=text name=offset value=\$offset\
size=20br;
 print Input the names of the desired additional cells in the spaces
provided.;
 // this is where your user will name the cells he asked to create
 for($i=1;$i=$additional_cells;$i++)
  {
  print $i input type=text name=user_added[$i] size=20br;
  }
 print input type=hidden name=additional_cells value=\$additional_cells\
;
 print input type=hidden name=start_button value=2;
 print input type=submit value=\ Hit it! \;
 print /form;
 }
if ($start_button==2)
   {
print $name.br.$temp.br.$time.br.$offset.br;
for($i=1;$i=$additional_cells;$i++)
{
print user cell .$i. .$user_added[$i].br;
}
}
?


2. Now comes the tricky part, and the part I'm unsure about.  You can
convert the user input in the above so that it becomes the names of the
input cells, or you can leave them in a numeric array.  Leaving them in a
numeric array will be easier to deal with later.
Also, other than the display of a table, what do you want the user input
for?  If you're planning on doing any data manipulation, then your coding
will get a bit hairy because you won't know what relation the user input
data has to your standard data (name, time, temp and offset).  Finally, if
you're planning on storing the data in a database table, each table will
need to be created on the fly--it can be done, but if you're struggling with
this, it'll take you some time to get the back end working.

Hope this helps,
Hugh

- Original Message -
From: Floyd Baker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: 'Hugh Danaher' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, November 27, 2002 5:24 PM
Subject: Re: [PHP] dynamic arraynames




 Well I might

Re: [PHP] dynamic arraynames

2002-11-27 Thread Floyd Baker


Well I might be in the wrong place.  I've also asked in the HTML list
now too but I'm still stuck and need some help.  

This is pretty much as clear as I can make it.  I'm up against a
mental block and even if it's as clear as glass to others I'm dead in
the water and would appreciate some pointers.  I have a bunch of
pieces but can't seem to string them together enough to make it work.

Just trying to build an x-y array of data input fields and then send
them recursive to be used further down the program.  

I can do this fine with a fixed number of columns and rows of user
input but I cannot figure out how to make this happen using a variable
number of columns.  I'm a complete array amateur and would appreciate
a little assistance...

I want it to look something like this:

Name  Temp  Time  OffsetEtc.  As needed...   
process 1[input]   [input]   [input]   [input]   [inputs] 
process 2[input]   [input]   [input]   [input]   [inputs] 
process 3[input]   [input]   [input]   [input]   [inputs] 
process 4[input]   [input]   [input]   [input]   [inputs]

Right now, for the three *basic* columns, I have the lines below in a
'while' loop.

INPUT TYPE='text' NAME='temp[]' VALUE='$temp' SIZE='10'
MAXLENGTH='10' 
INPUT TYPE='text' NAME='time[]' VALUE='$time' SIZE='10'
MAXLENGTH='10' 
INPUT TYPE='text' NAME='offs[]' VALUE='$offs' SIZE='10'
MAXLENGTH='10' 

But when it comes to adding additional columns that a user
determines are needed, I am lost.  Users might want to add 0, or 4, or
10 additional items...  I would like only that number of usable
input columns be on the input-form, identified for what they contain,
and then be passed to the next page

Again, many thanks in advance.

Floyd






On Sun, 24 Nov 2002 23:55:56 -0500, you wrote:

I'm sorry, but I'm still confused. Can you show us a sample of the data
in the database and what you want the resulting form to look like for
that data? Maybe that'll help.

---John Holmes...



--


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




Re: [PHP] dynamic arraynames

2002-11-27 Thread Floyd Baker


Well I might be in the wrong place.  I've also asked in the HTML list
now too but I'm still stuck and need some help.  

This is pretty much as clear as I can make it.  I'm up against a
mental block and even if it's as clear as glass to others I'm dead in
the water and would appreciate some pointers.  I have a bunch of
pieces but can't seem to string them together enough to make it work.

Just trying to build an x-y array of data input fields and then send
them recursive to be used further down the program.  

I can do this fine with a fixed number of columns and rows of user
input but I cannot figure out how to make this happen using a variable
number of columns.  I'm a complete array amateur and would appreciate
a little assistance...

I want it to look something like this:

Name  Temp  Time  OffsetEtc.  As needed...   
process 1[input]   [input]   [input]   [input]   [inputs] 
process 2[input]   [input]   [input]   [input]   [inputs] 
process 3[input]   [input]   [input]   [input]   [inputs] 
process 4[input]   [input]   [input]   [input]   [inputs]

Right now, for the three *basic* columns, I have the lines below in a
'while' loop.

INPUT TYPE='text' NAME='temp[]' VALUE='$temp' SIZE='10'
MAXLENGTH='10' 
INPUT TYPE='text' NAME='time[]' VALUE='$time' SIZE='10'
MAXLENGTH='10' 
INPUT TYPE='text' NAME='offs[]' VALUE='$offs' SIZE='10'
MAXLENGTH='10' 

But when it comes to adding additional columns that a user
determines are needed, I am lost.  Users might want to add 0, or 4, or
10 additional items...  I would like only that number of usable
input columns be on the input-form, identified for what they contain,
and then be passed to the next page

Again, many thanks in advance.

Floyd






On Sun, 24 Nov 2002 23:55:56 -0500, you wrote:

I'm sorry, but I'm still confused. Can you show us a sample of the data
in the database and what you want the resulting form to look like for
that data? Maybe that'll help.

---John Holmes...





--


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




Re: [PHP] dynamic arraynames

2002-11-27 Thread Floyd Baker



Very sorry for the dupes...  Kept thinking I had pressed reply instead
of reply all.  


--


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




Re: [PHP] dynamic arraynames

2002-11-24 Thread Floyd Baker

Thank you for your efforts. The ideas are helping but sorry I am not
clear.  Not used to expressing myself regarding the coding I do. 

What I am looking to do is this:

From a loop that is reading a list of titles, I want to input pieces
of information to each...  The input fields will be in a  column on a
form with the name of the array at the top.

In a loop to n:
print INPUT TYPE='text' NAME='fred[]' SIZE='10' MAXLENGTH='10' ;

Fred works fine hard coded but i get n fred's...  I need the
individual  array names to be whatever comes from the list, column by
column.

Maybe this is very simple but I am not seeing how it's done.

Floyd





On Sat, 23 Nov 2002 15:28:13 -0800, you wrote:

Floyd,
if you are using mysql then you can use the mysql_list_fields to get the
names of the mysql table's column (field) names, then do mysql_num_fields to
get the number of columns (fields), then fill the columns with whatever
using a while loop.
I've attached a php page that fetches this info from any size table then
displays the table.  You can extract the info you need and extend it with
check boxes etc.
Hope this helps.
Hugh


!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
meta http-equiv=Content-Type content=text/html; charset=utf-8
titleInput Data Page/title
?php include (css.txt); ?
/head
body bgcolor=#1D3E81 
h1font color=#33DATABASE TABLES/font/h1

form action=?php print $php_self? method=post
?php

print table cellpadding=7 border=1 bgcolor=#d5d5d5trtd;
print h6Database name:/h6input type=text name=db
STYLE=width:140px/tdtd;
print h6Username:/h6input type=text name=user STYLE=width:140px;
print h6Password:/h6input type=text name=pass STYLE=width:140px;
print /tdtd valign=middle align=centerinput type=submit value=\ go
\;
print input type=hidden name=start value=1;
print /td/tr/table/formbr;
if ($start==1)
 {
 $link=mysql_connect(localhost,$user,$pass);
 if (! $link) die(couldn't connect mysql);
 mysql_select_db($db,$link) or die (couldn't open $db .mysql_error());
 $tables=mysql_list_tables($db,$link);
 $num=mysql_num_rows($tables)-1;
 mysql_close($link);
 ?
 form action=?php print $php_self? method=post
 ?php
 print table cellpadding=7 border=1 bgcolor=#d5d5d5trtd;
 print h6Table Name: /h6select type=text name=table
STYLE=width:140pxoption;

 for ($i=0;$i=$num;$i++)
  {
  print option.mysql_tablename($tables,$i);
  }
 print /select;

 print /tdtdinput type=submit value=\ go  \;
 print input type=hidden name=start value=2;

 print input type=hidden name=db value=$db;
 print input type=hidden name=user value=$user;
 print input type=hidden name=pass value=$pass;
 print /td/tr/table/formbr;
 }

if ($start==2)
 {
 $link=mysql_connect(localhost,$user,$pass);
 if (! $link) die(couldn't connect mysql);
 mysql_select_db($db,$link) or die (couldn't open $db .mysql_error());

 $results=mysql_query(select * from $table);
 $fields = mysql_list_fields($db, $table, $link);
 $columns = mysql_num_fields($fields);
 mysql_close($link);
 print table width=95% bgcolor=#d5d5d5 border=1 cellspacing=0
cellpadding=0trtd align=centerh3$table/h3;
 print table width=100% bgcolor=#d5d5d5 border=1 cellspacing=0
cellpadding=4;
 print tr;
 for ($i = 0; $i  $columns; $i++)
  {
  print td align=center bgcolor=#6c6c6ch5font
color=white.mysql_field_name($fields, $i)./font/h5/td;
  }
 print /tr;
 print tr;
 for ($i = 0; $i  $columns; $i++)
  {
  print td align=center bgcolor=#fbfbfbh5.mysql_field_type($results,
$i)./h5/td;
  }
 print /tr;
 while ($a_row=mysql_fetch_row($results))
  {
  print tr;
  foreach($a_row as $field)
   {
   if ($field==)
{
$field=nbsp;;
}
   print td align=centerh5.$field./h5/td;
   }
  print /tr;
  }
 print /table/td/tr/table;
 }
?
/body
/html



- Original Message -
From: Floyd Baker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, November 23, 2002 2:07 PM
Subject: Re: [PHP] dynamic arraynames


 On Sat, 23 Nov 2002 10:58:02 -0500, you wrote:

  I am trying to generate arrays to hold inputs to columns.  Column
  titles are input to a table as needed.  They are read by the program
  and placed across the page.  Then an array goes under each column name
  to collect the inputs to the various rows.  Everything works except to
  dynamically change the name of the array.
 
 
  while($foo=mysql_fetch_array($mysql_result)){
  print INPUT TYPE=text NAME=correspondingfoo[];}
 
 Do you want this??
 
 print INPUT TYPE=text NAME= . $foo['something'] . [];
 
 ---John Holmes...


 No John.  I'm ok with simply inputting a value and otherwise using
 arrays that are hard coded and previously named but my problem is in
 creating different arrays on the fly to represent each column that
 there is a name for.  I want to end up with something like $meat[] and
 $potatoes[] and whatever else is needed from a list...  The list of
 meat, potatoes, etc determines how many arrays and their names.

 I'm not to swift when it comes to arrays and think I'm probably

RE: [PHP] dynamic arraynames

2002-11-24 Thread John W. Holmes
I'm sorry, but I'm still confused. Can you show us a sample of the data
in the database and what you want the resulting form to look like for
that data? Maybe that'll help.

---John Holmes...

 -Original Message-
 From: Floyd Baker [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, November 24, 2002 11:29 PM
 To: Hugh Danaher
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] dynamic arraynames
 
 
 Thank you for your efforts. The ideas are helping but sorry I am not
 clear.  Not used to expressing myself regarding the coding I do.
 
 What I am looking to do is this:
 
 From a loop that is reading a list of titles, I want to input pieces
 of information to each...  The input fields will be in a  column on a
 form with the name of the array at the top.
 
 In a loop to n:
 print INPUT TYPE='text' NAME='fred[]' SIZE='10' MAXLENGTH='10' ;
 
 Fred works fine hard coded but i get n fred's...  I need the
 individual  array names to be whatever comes from the list, column by
 column.
 
 Maybe this is very simple but I am not seeing how it's done.
 
 Floyd
 
 
 
 
 
 On Sat, 23 Nov 2002 15:28:13 -0800, you wrote:
 
 Floyd,
 if you are using mysql then you can use the mysql_list_fields to get
the
 names of the mysql table's column (field) names, then do
mysql_num_fields
 to
 get the number of columns (fields), then fill the columns with
whatever
 using a while loop.
 I've attached a php page that fetches this info from any size table
then
 displays the table.  You can extract the info you need and extend it
with
 check boxes etc.
 Hope this helps.
 Hugh
 
 
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 html
 head
 meta http-equiv=Content-Type content=text/html; charset=utf-8
 titleInput Data Page/title
 ?php include (css.txt); ?
 /head
 body bgcolor=#1D3E81 
 h1font color=#33DATABASE TABLES/font/h1
 
 form action=?php print $php_self? method=post
 ?php
 
 print table cellpadding=7 border=1 bgcolor=#d5d5d5trtd;
 print h6Database name:/h6input type=text name=db
 STYLE=width:140px/tdtd;
 print h6Username:/h6input type=text name=user
STYLE=width:140px;
 print h6Password:/h6input type=text name=pass
STYLE=width:140px;
 print /tdtd valign=middle align=centerinput type=submit
value=\ go
 \;
 print input type=hidden name=start value=1;
 print /td/tr/table/formbr;
 if ($start==1)
  {
  $link=mysql_connect(localhost,$user,$pass);
  if (! $link) die(couldn't connect mysql);
  mysql_select_db($db,$link) or die (couldn't open $db
.mysql_error());
  $tables=mysql_list_tables($db,$link);
  $num=mysql_num_rows($tables)-1;
  mysql_close($link);
  ?
  form action=?php print $php_self? method=post
  ?php
  print table cellpadding=7 border=1 bgcolor=#d5d5d5trtd;
  print h6Table Name: /h6select type=text name=table
 STYLE=width:140pxoption;
 
  for ($i=0;$i=$num;$i++)
   {
   print option.mysql_tablename($tables,$i);
   }
  print /select;
 
  print /tdtdinput type=submit value=\ go  \;
  print input type=hidden name=start value=2;
 
  print input type=hidden name=db value=$db;
  print input type=hidden name=user value=$user;
  print input type=hidden name=pass value=$pass;
  print /td/tr/table/formbr;
  }
 
 if ($start==2)
  {
  $link=mysql_connect(localhost,$user,$pass);
  if (! $link) die(couldn't connect mysql);
  mysql_select_db($db,$link) or die (couldn't open $db
.mysql_error());
 
  $results=mysql_query(select * from $table);
  $fields = mysql_list_fields($db, $table, $link);
  $columns = mysql_num_fields($fields);
  mysql_close($link);
  print table width=95% bgcolor=#d5d5d5 border=1 cellspacing=0
 cellpadding=0trtd align=centerh3$table/h3;
  print table width=100% bgcolor=#d5d5d5 border=1 cellspacing=0
 cellpadding=4;
  print tr;
  for ($i = 0; $i  $columns; $i++)
   {
   print td align=center bgcolor=#6c6c6ch5font
 color=white.mysql_field_name($fields, $i)./font/h5/td;
   }
  print /tr;
  print tr;
  for ($i = 0; $i  $columns; $i++)
   {
   print td align=center
 bgcolor=#fbfbfbh5.mysql_field_type($results,
 $i)./h5/td;
   }
  print /tr;
  while ($a_row=mysql_fetch_row($results))
   {
   print tr;
   foreach($a_row as $field)
{
if ($field==)
 {
 $field=nbsp;;
 }
print td align=centerh5.$field./h5/td;
}
   print /tr;
   }
  print /table/td/tr/table;
  }
 ?
 /body
 /html
 
 
 
 - Original Message -
 From: Floyd Baker [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Saturday, November 23, 2002 2:07 PM
 Subject: Re: [PHP] dynamic arraynames
 
 
  On Sat, 23 Nov 2002 10:58:02 -0500, you wrote:
 
   I am trying to generate arrays to hold inputs to columns.
Column
   titles are input to a table as needed.  They are read by the
program
   and placed across the page.  Then an array goes under each
column
 name
   to collect the inputs to the various rows.  Everything works
except
 to
   dynamically change the name of the array.
  
  
   while($foo=mysql_fetch_array($mysql_result)){
   print INPUT TYPE=text NAME=correspondingfoo[];}
  
  Do you want

RE: [PHP] dynamic arraynames

2002-11-23 Thread John W. Holmes
 I am trying to generate arrays to hold inputs to columns.  Column
 titles are input to a table as needed.  They are read by the program
 and placed across the page.  Then an array goes under each column name
 to collect the inputs to the various rows.  Everything works except to
 dynamically change the name of the array.
 
 
 while($foo=mysql_fetch_array($mysql_result)){
 print INPUT TYPE=text NAME=correspondingfoo[];}

Do you want this??

print INPUT TYPE=text NAME= . $foo['something'] . [];

---John Holmes...



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




Re: [PHP] dynamic arraynames

2002-11-23 Thread Floyd Baker
On Sat, 23 Nov 2002 10:58:02 -0500, you wrote:

 I am trying to generate arrays to hold inputs to columns.  Column
 titles are input to a table as needed.  They are read by the program
 and placed across the page.  Then an array goes under each column name
 to collect the inputs to the various rows.  Everything works except to
 dynamically change the name of the array.
 
 
 while($foo=mysql_fetch_array($mysql_result)){
 print INPUT TYPE=text NAME=correspondingfoo[];}

Do you want this??

print INPUT TYPE=text NAME= . $foo['something'] . [];

---John Holmes...


No John.  I'm ok with simply inputting a value and otherwise using
arrays that are hard coded and previously named but my problem is in
creating different arrays on the fly to represent each column that
there is a name for.  I want to end up with something like $meat[] and
$potatoes[] and whatever else is needed from a list...  The list of
meat, potatoes, etc determines how many arrays and their names.
  
I'm not to swift when it comes to arrays and think I'm probably stuck
on some simple misconception.  I'm trying to convert $meat to $meat[],
on the fly, to have something to input to...  I read today maybe I
don't need the brackets?  

Floyd


--


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




Re: [PHP] dynamic arraynames

2002-11-23 Thread Hugh Danaher
Floyd,
if you are using mysql then you can use the mysql_list_fields to get the
names of the mysql table's column (field) names, then do mysql_num_fields to
get the number of columns (fields), then fill the columns with whatever
using a while loop.
I've attached a php page that fetches this info from any size table then
displays the table.  You can extract the info you need and extend it with
check boxes etc.
Hope this helps.
Hugh


!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
meta http-equiv=Content-Type content=text/html; charset=utf-8
titleInput Data Page/title
?php include (css.txt); ?
/head
body bgcolor=#1D3E81 
h1font color=#33DATABASE TABLES/font/h1

form action=?php print $php_self? method=post
?php

print table cellpadding=7 border=1 bgcolor=#d5d5d5trtd;
print h6Database name:/h6input type=text name=db
STYLE=width:140px/tdtd;
print h6Username:/h6input type=text name=user STYLE=width:140px;
print h6Password:/h6input type=text name=pass STYLE=width:140px;
print /tdtd valign=middle align=centerinput type=submit value=\ go
\;
print input type=hidden name=start value=1;
print /td/tr/table/formbr;
if ($start==1)
 {
 $link=mysql_connect(localhost,$user,$pass);
 if (! $link) die(couldn't connect mysql);
 mysql_select_db($db,$link) or die (couldn't open $db .mysql_error());
 $tables=mysql_list_tables($db,$link);
 $num=mysql_num_rows($tables)-1;
 mysql_close($link);
 ?
 form action=?php print $php_self? method=post
 ?php
 print table cellpadding=7 border=1 bgcolor=#d5d5d5trtd;
 print h6Table Name: /h6select type=text name=table
STYLE=width:140pxoption;

 for ($i=0;$i=$num;$i++)
  {
  print option.mysql_tablename($tables,$i);
  }
 print /select;

 print /tdtdinput type=submit value=\ go  \;
 print input type=hidden name=start value=2;

 print input type=hidden name=db value=$db;
 print input type=hidden name=user value=$user;
 print input type=hidden name=pass value=$pass;
 print /td/tr/table/formbr;
 }

if ($start==2)
 {
 $link=mysql_connect(localhost,$user,$pass);
 if (! $link) die(couldn't connect mysql);
 mysql_select_db($db,$link) or die (couldn't open $db .mysql_error());

 $results=mysql_query(select * from $table);
 $fields = mysql_list_fields($db, $table, $link);
 $columns = mysql_num_fields($fields);
 mysql_close($link);
 print table width=95% bgcolor=#d5d5d5 border=1 cellspacing=0
cellpadding=0trtd align=centerh3$table/h3;
 print table width=100% bgcolor=#d5d5d5 border=1 cellspacing=0
cellpadding=4;
 print tr;
 for ($i = 0; $i  $columns; $i++)
  {
  print td align=center bgcolor=#6c6c6ch5font
color=white.mysql_field_name($fields, $i)./font/h5/td;
  }
 print /tr;
 print tr;
 for ($i = 0; $i  $columns; $i++)
  {
  print td align=center bgcolor=#fbfbfbh5.mysql_field_type($results,
$i)./h5/td;
  }
 print /tr;
 while ($a_row=mysql_fetch_row($results))
  {
  print tr;
  foreach($a_row as $field)
   {
   if ($field==)
{
$field=nbsp;;
}
   print td align=centerh5.$field./h5/td;
   }
  print /tr;
  }
 print /table/td/tr/table;
 }
?
/body
/html



- Original Message -
From: Floyd Baker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, November 23, 2002 2:07 PM
Subject: Re: [PHP] dynamic arraynames


 On Sat, 23 Nov 2002 10:58:02 -0500, you wrote:

  I am trying to generate arrays to hold inputs to columns.  Column
  titles are input to a table as needed.  They are read by the program
  and placed across the page.  Then an array goes under each column name
  to collect the inputs to the various rows.  Everything works except to
  dynamically change the name of the array.
 
 
  while($foo=mysql_fetch_array($mysql_result)){
  print INPUT TYPE=text NAME=correspondingfoo[];}
 
 Do you want this??
 
 print INPUT TYPE=text NAME= . $foo['something'] . [];
 
 ---John Holmes...


 No John.  I'm ok with simply inputting a value and otherwise using
 arrays that are hard coded and previously named but my problem is in
 creating different arrays on the fly to represent each column that
 there is a name for.  I want to end up with something like $meat[] and
 $potatoes[] and whatever else is needed from a list...  The list of
 meat, potatoes, etc determines how many arrays and their names.

 I'm not to swift when it comes to arrays and think I'm probably stuck
 on some simple misconception.  I'm trying to convert $meat to $meat[],
 on the fly, to have something to input to...  I read today maybe I
 don't need the brackets?

 Floyd


 --


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



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