Jump to content

Problem with my code html formatting of database


rosspaddock

Recommended Posts

Okay the problem Im having is that my code as below is printing out my table field names horizontaly with the values in the table fields directly below like so.

 

Fieldname1 Fieldname2 Fieldname3

Value 1 Value 1 Value 1

Value 2 Value 2 Value 2

Value 3 Value 3 Value 3

 

What i need it to do is like so:

 

Fieldname1  Value 1 Value 2 Value 3

Fieldname2  Value 1 Value 2 Value 3

Fieldname3  Value 1 Value 2 Value 3

 

I have played and played with the code and just can't get the display looking like this here is the code if anyone could tell me where it needs ajusting it would be fab.

 

//Parse result set

 

function parseresults($result) {

      if($line = mysql_fetch_array($result,MYSQL_ASSOC)){

                print"<table border=0 cellpadding =3>\n<tr>";

                //parse column names

                foreach ($line as $key => $value) {

                        print"<td bgcolor =CCCCCC><b>$key</b></td>";

                        }

                        print "</tr>\n";

                        //Reset data pointer

                        mysql_data_seek($result,0);

                        //step through data rows

                        while($line = mysql_fetch_row($result)) {

                              print "<tr bgcolor =FFFF99>";

                              //print each value in its own cell

                              foreach($line as $key => $value) {

                                      print"<td>$line[$key] </td>";

                                      }

                                      print "</tr>";

                                }

                                print"</table>\n";

                            }

                      }

 

 

The code at the mo brings back the field names in yellow with the values in the database underneath in Grey any help would be greatly appreciated.

Thanks

Ross

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.