[PHP] Dynamic Tables

2004-06-07 Thread Christopher J. Crane
What is the best way to produce a report listing the fieldname and then the
data in that field. It is a report containing only one row from a table, but
I don't want to hard code the fields since they change often.

I can get the field names dynamically like this:

$fields = mysql_list_fields("Network", "Subnets");
$num_columns = mysql_num_fields($fields);
for($ i = 0; $i < $num_columns; $i++) { echo mysql_field_name($fields,
$i); }

now is where I get confusedwhat I would like to happen is do a query on
a single row and put the results into mysql_fetch_assoc and during the prior
loop put the column name into the loop of the data. Something like:

$fields = mysql_list_fields("Network", "Subnets");
$num_columns = mysql_num_fields($fields);
$result  =  mysql_query("SELECT * FROM table1 WHERE ID = '$ID';
$field = mysql_fetch_assoc($result)
for($ i = 0; $i < $num_columns; $i++) {
echo "" . mysql_field_name($fields, $i) . ": " .
$field[mysql_field_name($fields, $i)] . "\n";

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



Re: [PHP] Dynamic tables

2003-10-17 Thread David Otton
On Fri, 17 Oct 2003 14:42:34 +0800, you wrote:

>Right now, I am able to change the colour of cells using a drop down menu, and
>when I clicked on "Reload" it still remains the colour that I have changed, but
>when I open the page in another browser, as I echoed the value "colour", the
>browser displayed a mixture of the colour code :grey, pink, blue, etc
>How can I do it in the way that when I opened up a new browser it will display
>only the colour that I have changed to earlier on?Hope to get some help
>soon...thanks for all help given.

You're trying to hold state. To do this, you need to use a cookie or a
session.

There are also several problems with the script you seem to be using (for
example, it's open to code injection). Hopefully, you'll be able to tease
some sense out of this:

 '#dedede', 'Pink' => '#ffb6c1',
'Blue' => '#87ceeb', 'Yellow' => '#00',
'Cyan' => '#af'); /* valid responses */

session_start();

if (isset ($_POST['textcolour']))
{
/* check that incoming textcolour is one of the permitted values */
if (in_array ($_POST['textcolour'], $valid_colours))
{
$_SESSION['textcolour'] = $_POST['textcolour'];
header ("Location: $PHP_SELF");
exit ();
}
}

/* if we don't have a colour, default to grey */
if (isset ($_SESSION['textcolour']) == FALSE)
{
$_SESSION['textcolour'] = $valid_colours['Grey'];
}

?>



Test



 $value)
{
if ($value == $_SESSION['textcolour'])
{
echo ("$colour");
} else {
echo ("$colour");
}
}
?>






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



[PHP] Dynamic tables

2003-10-16 Thread irinchiang

Hi all, 
   Having a slight problem with dynamic tables here.
I am trying to create a timetable using PHP, HTML, and MySQL, where all the
cells in the table are coloured and that the colour of the cells can be changed
using a drop down menu. Here's a snip of the code that I have done:


 class="Devi" width="15%" align="center" 
valign="middle">2PE1012


Grey
Pink
Blue
Yellow
Cyan


Right now, I am able to change the colour of cells using a drop down menu, and
when I clicked on "Reload" it still remains the colour that I have changed, but
when I open the page in another browser, as I echoed the value "colour", the
browser displayed a mixture of the colour code :grey, pink, blue, etc
How can I do it in the way that when I opened up a new browser it will display
only the colour that I have changed to earlier on?Hope to get some help
soon...thanks for all help given.

Regards, 
Irin.

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



Re: [PHP] Dynamic tables-Change cell colour with drop down menu[Scanned]

2003-10-02 Thread irinchiang
On Fri, Oct 03, 2003 at 11:27:25AM +0800, [EMAIL PROTECTED] wrote:
:
: I have tried using the methos you have mentioned. But it was not
: successful as the cell doesn't seem to be able to GET the COLOUR
: selected from the drop down menu. This is a small part of my code :
:
:  cell1 
:
: &
: 
: Red
: Grey
: white
: Pink
: Blue
: Yellow
: Cyan
: 

: No matter which colour I select. The cell only stay at "black" colour.
: I wonder why?Need some help here.

Eugene Lee <[EMAIL PROTECTED]> wrote:

If you're on a system that has global variables disabled, you must
switch to the superglobals.

 cell1 
or:
 cell1 


>>How to switch to the superglobals??Go php.ini and uncomment
"superglobals"??...

Regards,
Irin. 







Sorry misinterprete your message earlier on. I managed to get it solved. 
Thanks alot for your help anyway=)

Have a nice day.

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



Re: [PHP] Dynamic tables-Change cell colour with drop down menu[Scanned]

2003-10-02 Thread irinchiang
On Fri, Oct 03, 2003 at 11:27:25AM +0800, [EMAIL PROTECTED] wrote:
:
: I have tried using the methos you have mentioned. But it was not
: successful as the cell doesn't seem to be able to GET the COLOUR
: selected from the drop down menu. This is a small part of my code :
:
:  cell1 
:
: &
: 
: Red
: Grey
: white
: Pink
: Blue
: Yellow
: Cyan
: 

: No matter which colour I select. The cell only stay at "black" colour.
: I wonder why?Need some help here.

Eugene Lee <[EMAIL PROTECTED]> wrote:

If you're on a system that has global variables disabled, you must
switch to the superglobals.

 cell1 
or:
 cell1 


>>How to switch to the superglobals??Go php.ini and uncomment
"superglobals"??...

Regards, 
Irin.

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



Re: [PHP] Dynamic tables-Change cell colour with drop down menu[Scanned]

2003-10-02 Thread Eugene Lee
On Fri, Oct 03, 2003 at 11:27:25AM +0800, [EMAIL PROTECTED] wrote:
: 
: I have tried using the methos you have mentioned. But it was not
: successful as the cell doesn't seem to be able to GET the COLOUR
: selected from the drop down menu. This is a small part of my code :
: 
:  cell1 
: 
: &
: 
: Red
: Grey
: white
: Pink
: Blue
: Yellow
: Cyan
: 
: 
: No matter which colour I select. The cell only stay at "black" colour.
: I wonder why?Need some help here.

If you're on a system that has global variables disabled, you must
switch to the superglobals.

 cell1 
or:
 cell1 

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



RE: [PHP] Dynamic tables-Change cell colour with drop down menu[Scanned]

2003-10-02 Thread irinchiang


Hi :
I have tried using the methos you have mentioned. But it was not successful
as the cell doesn't seem to be able to GET the COLOUR selected from the drop
down menu. This is a small part of my code :

 cell1 

&

Red
Grey
white
Pink
Blue
Yellow
Cyan


No matter which colour I select. The cell only stay at "black" colour.
I wonder why?Need some help here.

Regards, 
Irin.

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



Re: [PHP] Dynamic tables-Change cell colour with drop down menu

2003-10-02 Thread irinchiang


I want it to be available on the SERVER side too..
For this, javascript is unable to do it. That is why I want to use only PHP to
the the dynamic table which I have mentioned. Any idea how can I change the
colour of the cell from a drop down menu?

Regards, 
Irin.

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



Re: [PHP] Dynamic tables-Change cell colour with drop down menu

2003-10-02 Thread Marek Kilimajer
[EMAIL PROTECTED] wrote:

I do not want to it using
javascript as java script can only display data on the client side but not the
server side.
You can make the data available on the client side.

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


RE: [PHP] Dynamic tables-Change cell colour with drop down menu[Scanned]

2003-10-02 Thread Michael Egan
One possible solution:

In the form create the dropdown menu with the colour name being displayed to the user 
but the hexadecimal value of the colour being stored in the value field, i.e.


Red


When user selects the colour this should give you the colour reference to use when 
displaying the resulting page, i.e. $colour, which you could then use when creating 
the cell in the table - 

HTH,

Michael Egan

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 02 October 2003 11:40
To: 'PHP General'
Subject: [PHP] Dynamic tables-Change cell colour with drop down
menu[Scanned]



Hi all:

I am doing a dynamic kinda timetable where all the cells are uniquely coloured.
And then for each cell, I would like to change its colour through a dropdown
menu. This dropdown menu should of course have a list of colours for me to
choose. Once I have selected the colour I want, the particular cell colour
should be changed to the colour which i have selected earlier on, once the page
is refreshed. Is there any way to do it using PHP ??I do not want to it using
javascript as java script can only display data on the client side but not the
server side.

Any help given are greatly appreciated.

Regards, 
Irin.

-- 
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



[PHP] Dynamic tables-Change cell colour with drop down menu

2003-10-02 Thread irinchiang

Hi all:

I am doing a dynamic kinda timetable where all the cells are uniquely coloured.
And then for each cell, I would like to change its colour through a dropdown
menu. This dropdown menu should of course have a list of colours for me to
choose. Once I have selected the colour I want, the particular cell colour
should be changed to the colour which i have selected earlier on, once the page
is refreshed. Is there any way to do it using PHP ??I do not want to it using
javascript as java script can only display data on the client side but not the
server side.

Any help given are greatly appreciated.

Regards, 
Irin.

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