Can I force it to display the data sorted by the primary key?

Here's the code: 
    // store table names in an array 
    $arr_tablenames[] = ''; 
     
    // store number of fields per table(index 0,1,2..) in an array 
    $arr_num_fields[] = ''; 
    for ($i=0; $i < $num_tables; $i++) { 
        $arr_tablenames[$i] = mysql_tablename($tables, $i); 
        $arr_num_fields[$i] = mysql_num_fields(mysql_db_query($dbname,
"select * from $arr_tablenames[$i]", $id_link)); 
    } 
     
    // store field names in a multidimensional array: 
    // [i] == table number, [ii] == field number for that table 
    for ($i=0; $i < $num_tables; $i++) { 
        for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) { 
            $result = mysql_db_query($dbname, "select * from
$arr_tablenames[$i]", $id_link); 
            $hash_field_names[$i][$ii] = mysql_field_name($result, $ii);

        }     
    } 
     
    for ($i=0; $i < $num_tables; $i++) { 
        echo("<center><h3> $arr_tablenames[$i] </h3></center>"); 
        echo('<table align="center" border="1"><tr>'); 
        $result = mysql_db_query($dbname, "select * from
$arr_tablenames[$i]", $id_link); 
        for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) { 
            echo("<th>"); 
            echo $hash_field_names[$i][$ii]; 
            echo("</th>"); 
        } 
        echo("</tr><tr>"); 
        $number_of_rows = @mysql_num_rows($result); 
        for ($iii = 0; $iii < $number_of_rows; $iii++) { 
            $record = @mysql_fetch_row($result); 
            for ($ii=0; $ii < $arr_num_fields[$i]; $ii++) { 
                echo("<td>"); 
                echo $record[$ii]; 
                echo("</td>"); 
            } 
        echo("</tr>"); 
        } 
        echo("</table>"); 
    }


Is that too much to sort through???


-----Original Message-----
From: Tony S. Wu [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 30, 2002 7:31 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Changing colors in table?

If the table's background color will be set when the page is first
loaded,
you can just use the bgcolor attribute of <td> tag.
If you want to dynamically change the background color, you'll need to
combine your page with javascript.

Tony S. Wu
[EMAIL PROTECTED]

"Nope, this world ain't perfect. But at least I know it's not because of
me."



Blue Tiger at [EMAIL PROTECTED] wrote:

> Okay.....
> Disclaimer: I am very much the newbie, so please bear with me.
> 
> I have a piece of code that displays an array from a MySQL table. One
> field in the table is blank (and is displayed as an empty column of
> cells) at the moment. I want to have the blank cells display an image,
> value, or change its background color based on whether the numerical
> values in the previous 4 fields meet certain criteria or not. Make
> sense? Maybe?
> 
> An example of what I want to show:
> If table 2 has a value that is less than 5, then the last cell
displayed
> changes color to reflect that.
> If table 2 has a value that is between 5 and 10, then the last cell
> displayed changes color to reflect that as well.
> 
> Please help if you can....many thanks in advance. (I can show my code
> thus far as well if that helps..)
> 
> Thanks, 
> Ryan




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

Reply via email to