kycivicboy Posted February 13, 2007 Share Posted February 13, 2007 OK i have my database setup to show weights of the item. How can i tell my php script to highlight the cell in the table or bold the weight in the table? i hope what im trying to say makes sense. instead of sorting it by the heaviest weight i just want to be able to highlight/or bold the heaviest weight so the names of the items stay in alphabetical order. and i will be able to tell which item is heavier. Any help would really be appreciated. thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2007 Share Posted February 13, 2007 Before you display them, loop through and pick out the heaviest. Then when you are displaying them, check to see if that's the one, and if it is, apply the style to the cell. Quote Link to comment Share on other sites More sharing options...
kycivicboy Posted February 13, 2007 Author Share Posted February 13, 2007 i understand what your saying but im just know basic php. could you post an example of some code that will loop through them and pick out the heaviest? and how to check to see if its the one when displaying them. the rest i should be able to figure out. thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2007 Share Posted February 13, 2007 If you post the code you already have, we can edit it. If you don't have any code written, you need to start there. Quote Link to comment Share on other sites More sharing options...
kycivicboy Posted February 13, 2007 Author Share Posted February 13, 2007 when i get home i will post the code i have. im at school right now. Quote Link to comment Share on other sites More sharing options...
kycivicboy Posted March 1, 2007 Author Share Posted March 1, 2007 sorry ive been busy lately. here is the code. I would like to highlight the heaviest weight in row 5. <tr> <td width="25%"><?php print( $row[1] ); ?> </font></td> <td width="25%"><?php print( $row[2] ); ?> </font></td> <td width="25%"><?php print( $row[3] ); ?> </font></td> <td width="25%"><?php print( $row[4] ); ?> </font></td> <td width="25%"><?php print( $row[5] ); ?> </font></td> </tr> <?php } mysql_free_result( $result ); ?> </table> Quote Link to comment Share on other sites More sharing options...
kycivicboy Posted March 1, 2007 Author Share Posted March 1, 2007 any help would be appreiated. thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted March 1, 2007 Share Posted March 1, 2007 As you only print 1 row, highlight that one - it must be the heaviest. What happened to the < font > tags to accompany the < /font> tags? Quote Link to comment Share on other sites More sharing options...
kycivicboy Posted March 2, 2007 Author Share Posted March 2, 2007 sorry i meant tot ake the font tags out.. they are not there anymore int he actual code. Quote Link to comment Share on other sites More sharing options...
jcbarr Posted March 2, 2007 Share Posted March 2, 2007 How is your database set up? Does each column have a weight value in it? Quote Link to comment Share on other sites More sharing options...
kycivicboy Posted March 2, 2007 Author Share Posted March 2, 2007 Row 5 is the only column with a weight value. row 1 is the id#, row 2 is the product name. row 3 is a description row 4 is purchase price and row 5 is the weight. Quote Link to comment Share on other sites More sharing options...
craygo Posted March 2, 2007 Share Posted March 2, 2007 try this <table align=center width=800> <?php $sql = "SELECT * FROM tablename"; $res = mysql_query($sql) or die (mysql_error()); $weight = array(); while($w = mysql_fetch_array($res)){ $weight[] = $w[5]; } $max = max($weight); mysql_free_result($res); $result = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_array($result)){ if($row[5] == $max){ $maxweight = "<b>".$row[5]."</b>"; } else { $maxweight = $row[5]; } ?> <tr> <td width="20%"><?php print( $row[1] ); ?> </font></td> <td width="20%"><?php print( $row[2] ); ?> </font></td> <td width="20%"><?php print( $row[3] ); ?> </font></td> <td width="20%"><?php print( $row[4] ); ?> </font></td> <td width="20%"><?php print( $maxweight ); ?> </font></td> </tr> <?php } ?> </table> Should be able to plug in your table info, I just pasted my working script Ray Quote Link to comment Share on other sites More sharing options...
kycivicboy Posted March 2, 2007 Author Share Posted March 2, 2007 ok that is working thanks. one more question. if i wanted to underline the highest price now in the list price (row 4) how could i do that. i think one i have this figured out i should be good to go. thanks for all the help so far.. Quote Link to comment Share on other sites More sharing options...
kycivicboy Posted March 2, 2007 Author Share Posted March 2, 2007 i figured it out on my own. thank you!! seems to be working now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.