phppup Posted February 23, 2012 Share Posted February 23, 2012 Let's try something simple: I have a form that retrieves data from database and organizes the numbers inside of a table (sometimes in an input box). Is there a simple code so that VALUES > zero will be in BOLD font? Quote Link to comment https://forums.phpfreaks.com/topic/257585-making-td-value-bold/ Share on other sites More sharing options...
Rifts Posted February 23, 2012 Share Posted February 23, 2012 if (value > 0) { echo "<b>$awesome_data</b>; } else { echo $awesome_data; } Quote Link to comment https://forums.phpfreaks.com/topic/257585-making-td-value-bold/#findComment-1320281 Share on other sites More sharing options...
dragon_sa Posted February 23, 2012 Share Posted February 23, 2012 use css <head> <style type="text/css"> input #bold { font-weight: bold; } </style> <?php do database query get results ?> </head> <form> <?php while($result=mysql_fetch_array($query)) { $value=result["somerow"]; if ($value>o) { echo "Some field name <input name='data' type='text' id='bold' value='$value' /><br/>"; } else { echo "Some field name <input name='data' type='text' value='$value' /><br/>"; } } ?> </form> as an example Quote Link to comment https://forums.phpfreaks.com/topic/257585-making-td-value-bold/#findComment-1320282 Share on other sites More sharing options...
phppup Posted February 23, 2012 Author Share Posted February 23, 2012 The items in the form are each genreated by a line like this: echo "".$row['ITEM1'].""; There many items. Some are zero, some are greater. Is there a tool (like *) that I can use with a > function for the entire form, or do i need to apply the form for every item individually? Quote Link to comment https://forums.phpfreaks.com/topic/257585-making-td-value-bold/#findComment-1320492 Share on other sites More sharing options...
Maq Posted February 23, 2012 Share Posted February 23, 2012 Are you saying each $row['ITEM'] from the database is equal to an entire input element? Quote Link to comment https://forums.phpfreaks.com/topic/257585-making-td-value-bold/#findComment-1320550 Share on other sites More sharing options...
Zane Posted February 23, 2012 Share Posted February 23, 2012 Show us your current code Quote Link to comment https://forums.phpfreaks.com/topic/257585-making-td-value-bold/#findComment-1320554 Share on other sites More sharing options...
phppup Posted February 24, 2012 Author Share Posted February 24, 2012 Each row contains quantities from a form. I then ECHO the form after submission and ECHO the values. I would like all values >0 to be BOLD. while($result=mysql_fetch_array($query)) {$value=result["somerow"]; if ($value>o) { echo "Some field name <input name='data' type='text' id='bold' value='$value' /><br/>"; } else{ echo "Some field name <input name='data' type='text' value='$value' /><br/>"; }} the above codeseems promising, but I'm not sure how to LOOP it so it evaluates ALL the values in their fields, or if there might be a better method. Quote Link to comment https://forums.phpfreaks.com/topic/257585-making-td-value-bold/#findComment-1320639 Share on other sites More sharing options...
bspace Posted February 24, 2012 Share Posted February 24, 2012 not to solve the main problem, but you shouldn't be using id="bold" in that loop, but class="bold" and amend the css to reflect this ID names should be unique to 1 html element Quote Link to comment https://forums.phpfreaks.com/topic/257585-making-td-value-bold/#findComment-1320647 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.