Hi Matt,

> couple of questions (I like to understand what I am doing to that I don't
> need to ask again)
 Well, okay, i understand and will try. Please take a look in the manuel too.

each() will return a array and sets the array pointer to the next element of 
the input array. The returned array contains the key and the value of the 
input array element. This function returns false when the end of the array 
reached.
List() makes a list of the values of an array.

So we do list($key,$value)=each($row) to walk trought the whole array we put 
this statement in a while loop. 

> the the value is not null then ??? don't understand the || $i==0

The first time you walk trought this while loop $i is 0, all other loops it 
is not 0 (cause the $i++ in the loop)

We need this, cause you said in your explanation. that you would the first 
element always ($i==0) and the other element only when there are not null 
values (empty($value))

> where are the column title being displayed for each row ??
the function mysql_fetch_row($database_result)
return an array with the column title/name (more exactly the name you have 
used in your query, SELECT column1, column2, so i mean  column1 here ) as key 
en the fieldvalue assinged to it as value. The result pointer is also set to 
the next row.

BE: 
--
$result=mysql_query=("SELECT name, address FROM users");
$row=mysql_fetch_row($result);
will be the same as:
$row["name"]="Matt";
$row["address"]="The Street 1";
--

So $key above is the same as your column title.

> as I see it there should be a seperate table per record.

Yepp

> Each table containing the field name on the left and then the data on the
> right.

Yepp.



Op donderdag 28 februari 2002 17:11, schreef u:
> great bit of php.......
>
> couple of questions (I like to understand what I am doing to that I don't
> need to ask again)
>
> what does this section do ???
>
> $i=0;
> while(list($key,$value)=each($row))
> {
> if(!empty($value) || $i==0)
> {
> ?>
>
> I think it is while there are rows in the array list the table key and data
> for each row,
>
> the the value is not null then ??? don't understand the || $i==0
>
>
> where are the column title being displayed for each row ??
>
> as I see it there should be a seperate table per record.
>
> Each table containing the field name on the left and then the data on the
> right.
>
> Is that clear to you ?
>
> Matt.
>
>
>
> -----Original Message-----
> From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 28, 2002 3:05 PM
> To: DARCY,MATTHEW (Non-HP-UnitedKingdom,ex2)
> Subject: Re: [PHP] Probably basic but seems advanced to me, PHP/SQL
> genera tion.
>
>
>
> while($row=mysql_fetch_row($result))
> {
> echo"<TABLE BGCOLOR=#191970 WIDTH=400 HEIGHT=20>";
> $i=0;
> while(list($key,$value)=each($row))
> {
> if(!empty($value) || $i==0)
> {
> ?>
>         <TR HEIGHT=14>
>                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> echo $key; ?> </FONT> </TD>
>         </TR>
>
>         <TR HEIGHT=14>
>                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> echo $value; ?> </FONT> </TD>
>         </TR>
> <?
> }
> $i++;
> }
> echo "</TABLE>";
> }
>
> Op donderdag 28 februari 2002 15:39, schreef u:
> > glad you understand,
> >
> > i had a hard time putting what I wanted into an email.
> >
> >
> >
> > -----Original Message-----
> > From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, February 28, 2002 2:45 PM
> > To: DARCY,MATTHEW (Non-HP-UnitedKingdom,ex2)
> > Subject: Re: [PHP] Probably basic but seems advanced to me, PHP/SQL
> > genera tion.
> >
> >
> > Hi Matt,
> >
> > Okay, i understand give me minutes.......
> >
> > Op donderdag 28 februari 2002 15:27, schreef u:
> > > Hi baz, thanks for the reply.
> > >
> > > I was thinking like this.
> > >
> > >
> > > TABLE LAYOUT.
> > >
> > >
> > > COLS:             POSITION_TITLE  POSITION_REFERENCE
>
> POSITION_CONTACT
>
> > > POSITION_SALARY   POSITION_GRADE  etc etc
> > > ROWS              Support Operator        11212
>
> jim
>
> > > davies                                    B
> > >           ben the boffin  ATJR                            dean taylor
> > > £12 PA            C+
> > >           toilet Cleaner  BOGS                            Kelly the
> > > cleaner                           U
> > >
> > >
> > > as you can see there are fields which will always be populated like
> > > POSITION TITLE and POSITION_REFERENCE but things like salary and grade
> > > may not be (there are more fields)
> > >
> > > when say salary is empty I would not like to display it
> > >
> > > Here is how the HTML would look for displaying rows 2 and 1
> > > ie  for row 2
> > >
> > > <HTML>
> > > <HEAD>
> > > <TITLE> YOUR SEARCH RESULTS </TITLE>
> > >
> > >
> > > <TABLE BGCOLOR=#191970 WIDTH=400 HEIGHT=20>
> > >         <TR WIDTH=400 HEIGHT=6 BGCOLOR=#ff9900>
> > >                 <TD WIDTH=400> <FONT FACE=arial SIZE=4
> > > COLOR=#191970><CENTER> <? ($row{"POSITION_TITLE") ?> </FONT></TD>
> > >         </TR>
> > >         <TR HEIGHT=14>
> > >                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> > > ($row["POSITION_REFERENCE"] ?> </FONT> </TD>
> > >         </TR>
> > >
> > >         <TR HEIGHT=14>
> > >                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> > > ($row["POSITION_CONTACT"] ?> </FONT> </TD>
> > >         </TR>
> > >
> > >         <TR HEIGHT=14>
> > >                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> > > ($row["POSITION_SALARY"] ?> </FONT> </TD>
> > >         </TR>
> > >
> > >     <TR HEIGHT=14>
> > >                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> > > ($row["POSITION_GRADE"] ?> </FONT> </TD>
> > >         </TR>
> > >
> > > </TABLE>
> > >
> > > # for row 1
> > > <TABLE BGCOLOR=#191970 WIDTH=400 HEIGHT=20>
> > >         <TR WIDTH=400 HEIGHT=6 BGCOLOR=#ff9900>
> > >                 <TD WIDTH=400> <FONT FACE=arial SIZE=4
> > > COLOR=#191970><CENTER> <? ($row{"POSITION_TITLE") ?> </FONT></TD>
> > >         </TR>
> > >         <TR HEIGHT=14>
> > >                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> > > ($row["POSITION_REFERENCE"] ?> </FONT> </TD>
> > >         </TR>
> > >
> > >         <TR HEIGHT=14>
> > >                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> > > ($row["POSITION_CONTACT"] ?> </FONT> </TD>
> > >         </TR>
> > >
> > >         <TR HEIGHT=14>
> > >                 <TD> <FONT FACE=arial SIZE=4 COLOR=ff9900> <?
> > > ($row["POSITION_GRADE"] ?> </FONT> </TD>
> > >         </TR>
> > >
> > > </TABLE>
> > >
> > >
> > >
> > >
> > > </HTML>
> > >
> > >
> > >
> > > The bottom line is I want to select all the fields from the table, and
> > > display in a html form ALL the fields that are not null.
> > >
> > > So if each record has 15 fields, I would like the 5 populated fields
> > > for row2 displayed and the 4 populated fields for row 1 displayed - I
> > > don't want to display empty fields.
> > >
> > >
> > > thanks,
> > >
> > > Matt.
> > >
> > >
> > >
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, February 28, 2002 2:16 PM
> > > To: DARCY,MATTHEW (Non-HP-UnitedKingdom,ex2)
> > > Subject: Re: [PHP] Probably basic but seems advanced to me, PHP/SQL
> > > genera tion.
> > >
> > >
> > > Hi Matt,
> > >
> > > How have your table to look?
> > > one big table or like in your first email
> > > 1 value
> > > numer value
> > > etc.
> > > each row apart?
> > >
> > > Bas

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

Reply via email to